AngularJS を使用して、「onload」引数を使用して、「子」コントローラー (含まれているテンプレートによって呼び出されるコントローラー) 内で定義された関数をトリガーすることは可能ですか?
例:
<!-- parent container -->
<div ng-include="'/path/template.html'" onload="childOnLoad()"></div>
<!-- template.html -->
<div ng-controller="childController">
<p ng-bind="txt"></p>
</div>
<!-- childController.js -->
app.controller('childController', function($scope) {
$scope.txt = "Test text";
$scope.childOnLoad = function() {
alert("Loaded!");
};
});
それは理にかなっていますか?または、次のように、単に childController 内で関数を呼び出す必要がありますか?
<!-- childController.js -->
app.controller('childController', function($scope) {
$scope.txt = "Test text";
$scope.childOnLoad = function() {
alert("Loaded!");
};
$scope.childOnLoad();
});