1. 程式人生 > >angularjs學習之五(angularjs中一般函式引數的傳遞)

angularjs學習之五(angularjs中一般函式引數的傳遞)

1.模型引數

直接使用變數名,不要加引號

<!doctype html>
<html ng-app="passAter">
	<head>
		<meta charset="utf-8"/>
	</head>
	<body>
		<div ng-controller="passCtrl">
		    <input type="text" ng-model="value"/>
			<button ng-click="alertfun(value)">click</button>
		</div>
	</body>
	<script src="./js/angular.min.js"></script>
	<script>
	  angular.module('passAter',[]).controller('passCtrl',['$scope',function($scope){
	      $scope.alertfun = function(param){
		      alert(param);
		  }
	  }])
	</script>
</html>


2. 普通引數

加上引號即可

將上面的value改為 'value'

就會直接彈出 value了