我正在開發web應用程序AngularJS。我有下面的表格。
<form name="form2" novalidate><multiselect class="input-xlarge" multiple="true"
ng-model="selectedCar" options="c.name for c in cars" change="selected()"></multiselect>
<input type="file" file-modelsr = "myFileDL" />
<input type="file" file-modelsr="myFileID" />
<input type="submit" value="{{ 'NEXT' | translate }}" class="blue-button" ng-click="saveDetail()">
下面是我的JS代碼。
var myapp = angular.module('RoslpApp');
(function() {
angular.module('RoslpApp').controller('CarOutside', ['$scope', '$http', '$translatePartialLoader', '$translate', '$state', '$stateParams', 'cfg', 'toastr', '$cookieStore', '$filter', '$anchorScroll', '$location', 'fileUpload',
function ($scope, $http, $translatePartialLoader, $translate, $state, $stateParams, cfg, toastr, $cookieStore, $filter, $anchorScroll, $location, fileUpload) {
$translatePartialLoader.addPart('ServiceRequest');
$translate.refresh();
var cookiePreferredLanguage = $cookieStore.get('PreferredLanguage');
var LoginID = $cookieStore.get("LoginID");
var baseurl = cfg.Baseurl;
$translate.use((cookiePreferredLanguage != null && cookiePreferredLanguage != undefined && cookiePreferredLanguage != "") ? cookiePreferredLanguage : 'de_AR');
$scope.name = 'World';
//Bind data to multi select dropdown(location)
$scope.cars = [{ id: 1, name: 'Audi' }, { id: 2, name: 'BMW' }, { id: 1, name: 'Honda' }];
$scope.selectedCar = [];
//Bind data to period
$scope.periodList = [{ id: 1, period: 'Audi' }, { id: 2, period: 'BMW' }, { id: 1, period: 'Honda' }];
if ($scope.form2.$valid) {
$scope.saveDetail = function() {
var fileDL = $scope.myFileDL;
var fileID = $scope.myFileID;
var uploadUrl = "/fileUpload";
fileUpload.uploadFileToUrl(file, uploadUrl);
};
} else {
alert("not valid");
}
}]);
})();
我得到下面的錯誤無法讀取屬性undefined
$valid
和無法弄清楚它爲什麼我收到此錯誤。任何幫助,將不勝感激。謝謝。
請添加更多的JS代碼 – Brian
增加。謝謝。另外我還有兩個指令 –