我在controller中为什么得不到ng-model的值呀
你给加一个id="username" 然后在你的suserChange方法中
$scope.suerChange = function () {
console.log($scope);
console.log(angular.element(document.getElementById('username')).scope());
}
看控制台,你就会发现他们其实是两个不同的$scope
解决办法,设置一个user对象,然后将username当成他的一个属性
$scope.user = {};
$scope.user.username = '';
这样你就可以拿到他的值了
方法修改成sureChange(username),不就行了