controller控制器js加载时添加事件
(function(){ var app = angular.module('SMCS.App'); app.controller('SerIoUsDiseaseCtrl',['$scope','$http','BaseURL','$modal','$rootScope','$upload',function($scope,$http,BaseURL,$modal,$rootScope,$upload){ $scope.$on('$viewContentLoaded',function() { $("#inputableDiseaseNameSearchSerIoUDisease").bind('blur',function(){ var diseaseval=$("#inputableDiseaseNameSearchSerIoUDisease").val(); if(diseaseval==""){ $scope.form.AKA120=''; $scope.DiseaseCode=""; } }) }); }]); })();
其他方法
//2,利用data-ng-init <div ng-controller="test"> <div data-ng-init="load()" ></div> </div> //注意:data-ng-init在controller里面才会启作用 bookControllers.controller('testInit','$routeParams',$routeParams) { $scope.load = function() { alert('code here'); } }]);
转载 :http://blog.51yip.com/jsjquery/1599.html