我想要进行表单登录。但是当我想在浏览器中看到结果时,没有任何事情发生。当我打开控制台时,错误是:
Uncaught SyntaxError:意外的令牌。 services.js:3
我不知道代码有什么问题。有人可以帮我吗?我是离子
的新人索引:
<!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 && 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')
})
表格登录:
<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>
答案 0 :(得分:0)
在您的服务中删除;在第一行。
angular.module(&#39;起动机&#39); &lt; ---这一个