0
我正在構建我的第一個角度應用程序,並期望將我的表單發佈到我的JSON數據中。angularjs我怎樣才能發表我的表單到JSON
這是我的形式:
<span ng-show="show">
<form name="inputForm" class="form-group" ng-controller="FormController as autoctrl" ng-submit="inputForm.$valid && autoctrl.addGegevens(gegeven)" novalidate>
<br>
<p> Type: <input type="text" name="type" ng-model="type" style="margin-left:52px; padding-left:5px; width:165px;" minlength="2" maxlength="10" required /></p>
<p>Bouwjaar: <input type="number" name="bouwjaar" ng-model="bouwjaar" style="margin-left:22px; padding-left:5px; width:165px;" minlength="4" maxlength="4" required /></p>
<p>Km: <input type="number" name="km" ng-model="km" style="margin-left:60px; padding-left:5px; width:165px;" minlength="2" maxlength="6" required /></p>
<p>Brandstof: <input id="select" name="brandstof" ng-model="brandstof" style="margin-left:20px; padding-left:5px;" minlength="3" maxlength="7" required/></p>
<p>Kenteken: <input type="text" name="kenteken" ng-model="kenteken" style="margin-left:22px; padding-left:5px; width:165px;" minlength="6" maxlength="9" required /></p>
<p>Datum: <input type="text" name="datum" ng-model="datum" style="margin-left:40px; padding-left:5px; width:165px;" minlength="3" maxlength="11" required /></p>
<p>checked: <input type="checkbox" name="checked" ng-model="checked" style="margin-left:28px;" required /></p>
<br>
<button class="btn btn-primary" type="submit" value="submit">Toevoegen</button>
<div>{{inputForm.$valid}}</div>
</form>
</span>
這是我app.js:
(function(){
var volkswagenApp = angular.module('volkswagenapp',[]);
volkswagenApp.controller('VolkswagenCtrl', [ '$http' , function($http){
var vw = this;
vw.gegevens = [];
$http.get('autos.json').success(function(data){
vw.gegevens = data;
});
}]);
volkswagenApp.controller('FormController',function(){
this.gegevens={};
/* this.addGegevens = function(gegeven) {
gegeven.gegevens.push(this.gegeven);
this.gegevens={};
}*/
this.addGegevens = function(gegeven){
this.gegevens.datum = Date.now();
vw.gegevens.push(this.gegeven);
this.gegeven = {};
}
});
})();
有人能告訴我,我錯了?我和他們在codechool上做了同樣的步驟。
史迪威不工作.. – Dann
錯誤:找不到變量:大衆 addGegevens @ HTTP://本地主機:8888/volkswagen2/app.js:24:19 fn b @ http:// localhost:8888/volkswagen2/angular/angular.min.js:126:129 e @ http:// localhost:8888/volkswagen2/angular/angular。 min.js:276:196 $ eval @ http:// localhost:8888/volkswagen2/angular/angular.min.js:145:347 $ apply @ http:// localhost:8888/volkswagen2/angular/angular。 min.js:146:57 http:// localhost:8888/volkswagen2/angular/angular.min.js:276:253 Sf @ http:// localhost:8888/volkswagen2/angular/angular.min.js:37:131 d @ http :// localhost:8888/volkswagen2/angular/angular.min.js:37:75 – Dann
這是我的錯誤,我試過所有的帖子,但我只是沒有得到它 – Dann