我想使用角度做一個簡單的提交,但是$ scope.account_create.submit函數從未在提交時被調用,我向表單添加了name屬性,確保提交按鈕位於表單標籤內,但仍然沒有運氣提交ng-submit的角度提交沒有被調用
控制器
var tapp = angular.module('tailorapp.controllers').controller(
'AccountCtrl',
['$scope', '$state' , '$stateParams', '$ionicLoading', '$resource', 'localStorageService', 'settings', 'api', 'notification',
function($scope, $state, $stateParams, $ionicLoading, $resource, localStorageService, settings, api, notification) {
var _returnPath = $stateParams.returnPath;
$scope.mode = "signup";
$scope.account_create = {};
$scope.showSignIn = function(){
$scope.mode = "signin";
};
$scope.showSignUp = function(){
$scope.mode = "signup";
};
$scope.account_create.submit = function(item, event) {
_create_account($scope.account_create).success(function(data){
$state.go(_returnPath);
});
};
的Html
<ion-view title="Account">
<ion-nav-buttons side="right">
<button class="button button-icon icon ion-bag righthd-icon" ng-click="gotoCart();"></button>
<button class="button button-icon icon ion-person righthd-icon"></button>
</ion-nav-buttons>
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content class="has-header">
<div ng-show="mode == 'signup'">
<form name="account_create" ng-submit="account_create.submit()">
<div class="card">
...
<div class="item item-divider">
<button class="button button-positive" type="submit">Create Account</button>
哪個變量名? account_create?只是嘗試過,並且老舊 – 2014-09-27 20:45:55
我沒有注意到你是在命名你的表格,請參閱我的編輯 – 2014-09-27 23:27:17