Faizah Pratiwi Faizah Pratiwi - 1 year ago 220
Javascript Question

Uncaught SyntaxError: Unexpected token in Ionic

I want to make a form login. But when i want to see the result in browser, nothing happen. when i open console, the error is :

Uncaught SyntaxError: Unexpected token . services.js:3

I dont know whats wrong with the code. Anyone can help me please? I'm new in ionic

index :

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

<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>
<body ng-app="starter" ng-controller="AppCtrl">

controller :


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


services :


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


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


.config(function ($httpProvider){

app.js :

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

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

if(window.StatusBar) {

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


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 class="item item-input">
<input type="password" placeholder="Password" ng-model="user.password">
<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>

Answer Source

In your services remove the ; in the first line.

angular.module('starter'); <--- This one

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download