Miałem do czynienia z takim problemem, kiedy dodałem kontroler do mojego kodu trasy, nie udało się uzyskać nieoczekiwanego identyfikatora. Nie mam pojęcia dlaczego tak się dzieje To jest mój routeProvider:Nieoczekiwany identyfikator podczas dodawania kontrolera do ngRoute
app.config(function($routeProvider) {
$routeProvider
.when("/login", {
title: 'Login',
templateUrl: 'assets/login.html'
controller: authCtrl
})
});
I to jest mój kontroler:
app.controller('authCtrl', function ($scope, $rootScope, $routeParams, $location, $http, Data) {
//initially set those objects to null to avoid undefined error
$scope.login = {};
$scope.signup = {};
$scope.doLogin = function (customer) {
Data.post('login', {
customer: customer
}).then(function (results) {
Data.toast(results);
if (results.status == "success") {
$location.path('dashboard');
}
});
};
$scope.signup = {email:'',password:'',name:'',phone:'',address:''};
$scope.signUp = function (customer) {
Data.post('signUp', {
customer: customer
}).then(function (results) {
Data.toast(results);
if (results.status == "success") {
$location.path('dashboard');
}
});
};
$scope.logout = function() {
Data.get('logout').then(function (results) {
Data.toast(results);
$location.path('login');
});
}
});
podaję takich ścieżek w moim HTML:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"/>
<script src="app/angular-route.min.js"></script>
<script src="app/angular-animate.min.js" ></script>
<script src="app/toaster.js"></script>
<script src="app/app.js"></script>
pominięcia przecinek ',' po kluczu templateUrl –