Неперехваченная синтаксическая ошибка: неожиданный токен в Ionic

#javascript #angularjs #ionic-framework

#javascript #angularjs #ionic-framework

Вопрос:

Я хочу создать форму входа в систему. Но когда я хочу увидеть результат в браузере, ничего не происходит. когда я открываю консоль, ошибка :

Неперехваченная синтаксическая ошибка: неожиданный токен . services.js:3

Я не знаю, что не так с кодом. Кто-нибудь может мне помочь, пожалуйста? Я новичок в ionic

Указатель :

 <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
    <script src="js/constant.js"></script>
  </head>
  <body ng-app="starter" ng-controller="AppCtrl">
  <ui-view></ui-view>
  </body>
</html>
  

контроллер :

 angular.module('starter')

.controller('AppCtrl', function($scope, $state, $ionicPopup, AuthService, AUTH_EVENTS){

});
  

Услуги :

 angular.module('starter');

.service('AuthService', function($q, $http, API_ENDPOINT) {
    return {

    };
})

.factory('AuthInterceptor', function($rootScope, $q, AUTH_EVENTS){
    return {

    };
})

.config(function ($httpProvider){
    $httpProvider.interceptors.push('AuthInterceptor');
});
  

app.js :

 angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova amp;amp; window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider){
  $stateProvider
  .state('outside',{
    url : '/outside',
    abstract : true,
    templateUrl : 'templates/outside.html'
  })
  .state('outside.login',{
    url : '/login',
    templateUrl : 'templates/login.html',
    controller : 'LoginCtrl'
  })

  $urlRouterProvider.otherwise('/outside/login')
})
  

form login :

 <ion-view view-title="Please Sign in">
    <ion-content class="padding">
        <div class="list">
            <label class="item item-input">
                <input type="text" placeholder="Name" ng-model="user.name">
            </label>
            <label class="item item-input">
                <input type="password" placeholder="Password" ng-model="user.password">
            </label>
        </div>
        <button class="button button-full button-balanced" ng-click="login()">Login</button>
        <button class="button button-full button-clear button-positive" ui-sref="outside.register">Register Now!</button>
    </ion-content>
</ion-view>
  

Комментарии:

1. удалить ; из angular.module(‘starter’);

Ответ №1:

В ваших сервисах удалите ; в первой строке.

angular.module(‘starter’); <— Этот