我無法使用.Net部分回傳進行角處理。角模板和.NET部分回傳
問題是基本上相同此:Re-initialize Angular bindings after partial postback
基本上我有在其上我有角應用一個標籤,然後我有一些C#控制第二個選項卡,我必須做的翼片,當我之間部分回發回到我的應用程序,沒有什麼。
我已經嘗試使用ngView進行路由,然後我嘗試了$route.reload()
(它進入控制器,我可以看到模板正在被拉下來,但頁面上的結果是沒有的)。然後我嘗試compile(templateCache.get(lazyTableControllerRoute.current.templateUrl))(scope)
如提到here。沒有。
請幫助:)
每次回發我頁面上把這個網站後:
LiteralControl lazyControl = new LiteralControl("<div ng-app=\"LazyLoadingApp\" style=\"padding:10px\" ng-controller=\"LazyTableController\" ng-view><lazy-table> </lazy-table></div>");
Controls.Add(lazyControl);
而且一些配置常量像templateUrl
。
這裏是我的代碼:
var app = angular.module('LazyLoadingApp', ['ui.bootstrap', 'ngRoute'], function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
app.config(function ($routeProvider, $locationProvider, tableTemplateUrl) {
$routeProvider.when('/Page.Web.UI/sptl_project.aspx', {
controller: 'LazyTableController',
templateUrl: tableTemplateUrl,
});
// configure html5 to get links working on jsfiddle
$locationProvider.html5Mode(true);
});
//**This objects I am using after partial postback to check in the console if e.g. $route.reload() works..**
var lazyTableControllerRoute = null;
var templateCache = null;
var compile = null;
var scope = null;
app.directive('lazyTable', ['tableTemplateUrl',
function (tableTemplateUrl) {
return {
name: 'lazyTable',
priority: 0,
restrict: 'E', // E = Element, A = Attribute, C = Class, M = Comment
templateUrl: tableTemplateUrl
};
}
]).controller('LazyTableController', ['$scope', '$rootScope', 'lazyFactory', 'opsPerRequest', 'header', '$route', '$templateCache', '$compile',
function ($scope, $rootScope, lazyFactory, opsPerRequest, header, $route, $templateCache, $compile) {
lazyTableControllerRoute = $route;
var loadingPromise = null;
templateCache = $templateCache;
compile = $compile;
scope = $scope;
(...) rest is not important
UPDATE:
我與require.js努力。(再次,它的工作後,滿頁面加載。)我的想法是引導元部分回傳後。 我構建了簡單的測試用例,在更新面板中隨着我的應用程序有一個簡單的按鈕,只是部分回發。點擊(當應用程序消失)之後,我試着在控制檯:
angular.bootstrap(document, ['LazyLoadingApp'])
但後來我得到了錯誤,我無法刪除:
App Already Bootstrapped with this Element 'document'
這裏是plunker在require.js方式的應用程序(但請保留記住它只是用於代碼審查的目的..)
謝謝你的回答。我沒有使用它,當我嘗試「require.js的方式」我沒有刪除ng-app標籤。 – 2014-09-04 11:20:56
lazycontrol如何使用?爲什麼它包含ng-app? – 2014-09-04 11:22:35
你可以在這裏看到,lazycontrol包含ng-app,因爲那是我的第一個方法 - 正常的角度注入。 請不要更新本身連接代碼上面的「UPDATE」,因爲我做了一些修改爲require.js工作 - 就像從頁面移除NG-app並添加ngview .. – 2014-09-04 11:27:57