天天看點

angularjs 實作 window.onload() $(document).ready() 的方法

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', ['$scope', '$routeParams',
	function($scope, $routeParams) {
		$scope.load = function() {
		alert('code here');
	}
}]); 
           

轉載 :http://blog.51yip.com/jsjquery/1599.html

繼續閱讀