$includeContentLoaded每次ngInclude更新时都会被触发.
$scope.$on('$includeContentLoaded', function() {
// Emitted every time the ngInclude content is reloaded
});
Run Code Online (Sandbox Code Playgroud)
我想做的是,监听一个特定的ngInclude加载,如回调:
$scope.includePath('/path/to/iclude', function() {
// Fired when the includePath ngInclude have finished loading
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
小智 5
你可以使用"onload"标签:
<div ng-include="url" onload="test(url)">
</div>
Run Code Online (Sandbox Code Playgroud)
并在范围函数中检查url,例如:
$scope.test = function(url){
switch(url) {
case '/path/to/iclude':
/*******YOUR CODE***********/
break;
}
}
Run Code Online (Sandbox Code Playgroud)