In AngularJS, I have a ng-repeat for . Now what I want to do -
On ng-repeat, I want to do ng-init like
<tr ng-repeat="blah in blah" ng-init($event) />
The $event works fine with ng-click($event). How to do the same for ng-init?
In AngularJS, I have a ng-repeat for . Now what I want to do -
On ng-repeat, I want to do ng-init like
<tr ng-repeat="blah in blah" ng-init($event) />
The $event works fine with ng-click($event). How to do the same for ng-init?
In HTML
<tr ng-repeat="blah in blahs" ng-init="$last && done()" />
Inside your controller
function myControllerFunc($scope, $element){
$scope.done= function(){
//do something with $element
}
}
In ng-init cannot exists $event. Use a directive.
<div ng-app="myApp" ng-controller="myCtrl">
<input type="text" my-ng-init="myFunc"><br>
</div>
<script>
var app = angular.module('myApp', []);
app.directive('myNgInit', function() {
return {
scope: {
myNgInit: '&'
},
link: function(scope, element, attributes) {
scope.myNgInit()(element);
}
};
});
app.controller('myCtrl', function($scope) {
$scope.myFunc= function($element) {
console.log($element);
}
});
</script>