控制器作为 版本(推荐)
这里的模板
<div ng-app="example" ng-controller="myController as $ctrl"> <input type="text" ng-model="$ctrl.searchText" /> <button ng-click="$ctrl.check()">Check!</button> {{ $ctrl.searchText }}</div>JS
angular.module('example', []) .controller('myController', function() { var vm = this; vm.check = function () { console.log(vm.searchText); }; });最好是使用Angular 2.x或Angular 1.5或更高版本的组件
旧 方法(不推荐)
不建议这样做,因为字符串是原始的,强烈建议使用对象代替
在您的标记中尝试
<input type="text" ng-model="searchText" /><button ng-click="check(searchText)">Check!</button>{{ searchText }}而这在您的控制器中
$scope.check = function (searchText) { console.log(searchText);}


