2016-11-28 3 views
1

私はを使ってウェブページに "aa.html"をロードします。 "aa.html"に "ng-repeat"ディレクティブがあり、ロード後 "ng-repeat" wasn angularjsで実行されていますが、DOMに直接表示されますが、 "aa.html"コンテンツを$( "#div1")の中に直接配置すると、anglejsで実行できます。このページをロードするjqueryの後で、この「ng-repeat」をangularjsに実行させるにはどうすればよいですか?非同期で "ng-repeat"を実行する

+0

ロードするかどうかを判断するロジックが必要なので、ng-includeは使用できません。 –

答えて

2

あなたは

registerController( 'appnameの'、 'コントローラ'、 "temolatename")

jqueryの成功あなたにその後

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(); 
}); 

}

contorllerを登録する必要があります

angular.element("element").scope().run(); 
    angular.element("element").scope().$apply(); 
関連する問題