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);
相關文章
相關標籤/搜索