angularJs为什么当我保存表单数据到数据库之时,在取不到与表单输入框绑定的model的值
页面控制器定义如下:
appCtrls.controller('productAddCtrl', function ($scope,productService,localStorageService,$state) {
$scope.productName = '';
$scope.remark = '';
$scope.$watch('productName',function(){
})
$scope.addNewProduct=function(){
productService.addNewProduct($scope.productName,$scope.remark,localStorageService.getLocalStorage("user").userId);
$state.go("tab.crm-productList");
}
})
页面代码如下:
**<ion-view view-title="新产品">
<ion-nav-buttons side="right">
<a class="button button-clear" ng-click="addNewProduct()">完成</a>
</ion-nav-buttons>
<ion-nav-buttons side="left" >
<a class="button button-clear" ui-sref="tab.crm-productList">取消</a>
</ion-nav-buttons>
<ion-content class="no-padding">
<script id="templates/form-errors.html" type="text/ng-template">
<div class="form-error" ng-message="required">这是必填项</div>
<div class="form-error" ng-message="maxlength">This field is must be less than 50 characters</div>
</script>
<form name="addProductForm" novalidate>
<div class="list">
<div class="item item-divider">基本信息</div>
<label class="item item-input" ng-class="{'has-error':addCustomerForm.name.$invalid}">
<textarea type="text" name="name" placeholder="产品名称" required
ng-maxlength="1000" ng-model="productName">
</textarea>
<div>{{productName}}</div>
</label>
<div class="form-errors" ng-messages="addProductForm.name.$error"
ng-messages-include="templates/form-errors.html">
<div class="form-error" ng-message="maxlength">请输入不超过1000位字符</div>
</div>
<div class="item item-divider">其他信息</div>
<label class="item item-input" ng-class="{'has-error':addCustomerForm.remark.$invalid}">
<textarea type="text" name="remark" placeholder="备注"
ng-maxlength="5000" ng-model="remark">
</textarea>
<div>{{remark}}</div>
</label>
<div class="form-errors" ng-messages="addProductForm.remark.$error"
ng-messages-include="templates/form-errors.html">
<div class="form-error" ng-message="maxlength">请输入不超过5000位字符</div>
</div>
</div>
</form>
</ion-content>
</ion-view>**
执行addNewProduct该方法之时,不管在页面输入什么,点击完成后$scope.productName,$scope.remark都为空
我是个壞蛋
9 years, 5 months ago