0
我是AngularJS的新手,我如何從我的視圖更新ng-model的值? 現在我有窗體,我正在更新app_key輸入,但是當我調用我的模塊並檢查$ scope.variable時,值沒有改變。從視圖中修改ng-model
這裏我的代碼
<div>
<br>
<div class="field_row">
<label for="app_key">AppKey:</label>
<input id="app_key" type="text" ng-model="appKey"> --> this is the input that I´m changing the value
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info" ng-click="selectUser()">
Select
</button>
</div>
而我的模塊中我有方法selectUser
$scope.selectUser = function() {
$scope.setAppKey($scope.appKey); --> Here the appKey it´s not modified
};
解決方案
我不知道爲什麼,但要使它工作,我需要將ng模型傳遞給控制器功能
<input id="app_key" type="text" ng-model="appKey" ng-change="changeAppKey(appKey)">
如果你定義在'html'控制器? –
是的,它以前定義在html – paul
你在瀏覽器控制檯上有任何錯誤嗎? –