ionic中数据双向绑定无效,思考angularjs做用域

一:使用ng-model进行双向绑定无效案例javascript

1.在html中html

<input type="text" placeholder="搜索" ng-model="password">

2.在controller中没法取到值java

console.log($scope. password);

二:解决方案就是将password放在user对象双向绑定

1.html中paasword换成下面形式user.passwordcode

<input type="text" placeholder="搜索" ng-model="user.password">

2.在controller中定义对象user,将password放进去就能够了htm

$scope.user = {};
console.log($scope.user.password);
相关文章
相关标签/搜索