您需要註冊contorller
function registerController(moduleName, controllerName, template, container) {
// Load html file with content that uses Ctrl controller
//$(template).appendTo(container);
// Here I cannot get the controller function directly so I
// need to loop through the module's _invokeQueue to get it
var queue = angular.module(moduleName)._invokeQueue;
for (var i = 0; i < queue.length; i++) {
var call = queue[i];
if (call[0] == "$controllerProvider" &&
call[1] == "register" &&
call[2][0] == controllerName) {
controllerProvider.register(controllerName, call[2][1]);
}
}
angular.injector(['ng', moduleName]).invoke(function ($compile, $rootScope) {
$compile($("#" + template))($rootScope);
$rootScope.$apply();
});
}後
在你的jQuery成功
registerController( '應用程序名稱', '控制器', 「temolatename」)
angular.element("element").scope().run();
angular.element("element").scope().$apply();
我不能使用ng-include,因爲它需要確定是否加載它的邏輯。 –