Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-include onload not working anymore in angularjs 1.2.0 rc

Tags:

angularjs

I am using angular's ng-include like this :

main html:

<span ng-include="'tpl.html'" ng-controller="TplCtrl" onload="loadMe()"></span>

template tpl.html:

<h2>{{ tplMessage }}</h2>

the controller:

$scope.loadMe = function () {
        $scope.tplMessage =  'template';
    }
})

this was working fine with angularjs 1.1.5 but not anymore in 1.2.0 rc 3

here is a plunkr : http://plnkr.co/edit/zYRevS?p=preview

any idea how to make this work with 1.2.0 ?

edit: i saw this : https://github.com/angular/angular.js/issues/3584#issuecomment-25279350 but can't find the answer to this problem here.

like image 963
François Romain Avatar asked Oct 16 '13 16:10

François Romain


1 Answers

ok i found the answer here : https://github.com/angular/angular.js/issues/3584#issuecomment-25857079

ng-include can't be on the same element as ng-controller. In 1.1.5, it was working

here is a working updated plunker with an html element wrapping the ng-include: http://plnkr.co/edit/CB8jec?p=preview

like image 185
François Romain Avatar answered Nov 15 '22 06:11

François Romain