I\'m starting to play around with AngularJS forms in jsfiddle and I\'ve come across a problem already where a very simple form example is not working as expected. All I have
I wrote a directive to deal with this issue. Its an attribute that you can put on your form and pass a function to which will execute when the form is ready.
Javascript
angular.module('app').directive('formInit', function(){
return {
restrict: 'A',
scope: {
init: '&formInit'
},
controller: function($scope, $element){
var name = null;
if ($element[0] && $element[0].name){
name = $element[0].name;
}
var listener = $scope.$watch('init', function(){
if ($scope[name] && $scope.init){
$scope.init();
listener();
}
});
}
};
});
Example HTML
Where testing is a function on your controllers scope.