I'm starting with AngularJS and I need to bind "load" and "error" events to the iframes:
<ul data-ng-controller="WebServicesCtrl">
<li data-ng-repeat="webservice in webservices">
<a href="{{webservice.wsdl}}">{{webservice.name}}</a>
<iframe src="{{webservice.wsdl}}" class="hidden"></iframe>
</li>
</ul>
I tried to use $scope.watch and $scope.apply without success. I need to bind events right on iframe creation, since it will autoload the given src. Something like this:
app.controller('WebServicesCtrl', function WebServicesCtrl($scope, $http) {
$http.get('/webservices').success(function(data /* from expressjs, yaaay! */) {
$scope.webservices = data;
/* make iframes listen to load and error right after scope change,
before AngularJS inject them. */
});
});
I MUST NOT use <iframe onload="" onerror="" />.
I would like to know the jQuery form. The "pure AngularJS" case is welcome too. Just don't recall that jQuery is not needed. Sometimes we got huge legacy and things can't be beautiful.
Should I use $injector or something like that? That documentation is so young that hurts.
Feel like I'll have to study the source code soon.