Wenn ich versuche, die ng-submit - submitForm() -Funktion aufzurufen, kann ich die Funktion nicht aufrufen, und es tut nichts. Wie löse ich es?Senden Formular und Cordova Funktionen werden nicht aufgerufen
(function() {
'use strict';
/**
* @ngdoc function
* @name app.controller:MainCtrl
* @description
* # MainCtrl
* Controller of the app
*/
angular.module('app')
.controller('MainCtrl', ['$scope', 'cordova', function ($scope, cordova) {
console.log("Hello...");
cordova.ready.then(function() {
alert('Cordova is ready');
console.log("Ready....");
});
// function to submit the form after all validation has occurred
this.submitForm = function() {
console.log("Submit form...");
// check to make sure the form is completely valid
if ($scope.userForm.$valid) {
alert('our form is amazing');
console.log("For submitted..")
}
};
}]);
})();
Ich habe es in app.js as - (function() { 'Verwendung streng'; Winkel .module ('app' [ 'ngRoute', 'ngCookies']) CONFIG (config); . Config $ inject = [ '$ routeProvider', '$ locationProvider']; Funktion config ($ routeProvider, $ locationProvider) { $ routeProvider .when ('/', { Controller: 'MainCtrl', templateUrl: 'views/main.html', controllerAs: 'Haupt' }) .otherwise ({redirectTo: '/'}); } })(); – Smitha
Großartig @Smitha, dann das: 'ng-controller =" MainCtrl as main "' ist nicht notwendig. – slackmart