Javascript 如何将登录页面加载为第一页
我使用的是离子框架。我试图加载登录页面作为第一页,但看不到它只是得到一个空页面。 我的代码看起来像Javascript 如何将登录页面加载为第一页,javascript,angularjs,ionic,Javascript,Angularjs,Ionic,我使用的是离子框架。我试图加载登录页面作为第一页,但看不到它只是得到一个空页面。 我的代码看起来像 app.js: 和控制器: .controller('AppCtrl', function ($scope, $state, $ionicModal) { $ionicModal.fromTemplateUrl('templates/login.html', function(modal) { $scope.login
app.js: 和控制器:
.controller('AppCtrl', function ($scope, $state, $ionicModal) {
$ionicModal.fromTemplateUrl('templates/login.html', function(modal) {
$scope.loginModal = modal;
},
{
scope: $scope,
animation: 'slide-in-up',
focusFirstInput: true
}
);
//Be sure to cleanup the modal by removing it from the DOM
$scope.$on('$destroy', function() {
$scope.loginModal.remove();
});
.controller('LoginCtrl', function ($scope, $state, AuthenticationService) {
$scope.message = "";
$scope.user = {
username: null,
password: null
};
$scope.login = function () {
AuthenticationService.login($scope.user);
};
$scope.$on('event:auth-loginRequired', function (e, rejection) {
console.log('handling login required');
$scope.loginModal.show();
});
$scope.$on('event:auth-loginConfirmed', function () {
$scope.username = null;
$scope.password = null;
$scope.loginModal.hide();
});
但还是看不见。
我的应用程序看起来像
但是没有主页。
Thnx 尝试更改app.config部分
app.config(function ($stateProvider) {
$stateProvider.otherwise({ redirectTo: '/login' });
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
}).state('login', {
url: "/login",
templateUrl: "login.html page url",
controller: 'login controller'
}));
不需要编写任何代码
appcontroller'。无论何时运行应用程序,url路径都应为空。所以这一行是$stateProvider.otherwise({redirectTo:'/login'})代码>帮助打开登录屏幕。尝试更改app.config部分
app.config(function ($stateProvider) {
$stateProvider.otherwise({ redirectTo: '/login' });
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
}).state('login', {
url: "/login",
templateUrl: "login.html page url",
controller: 'login controller'
}));
不需要编写任何代码appcontroller'。无论何时运行应用程序,url路径都应为空。所以这一行是$stateProvider.otherwise({redirectTo:'/login'})代码>帮助打开登录屏幕。尝试更改app.config部分
app.config(function ($stateProvider) {
$stateProvider.otherwise({ redirectTo: '/login' });
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
}).state('login', {
url: "/login",
templateUrl: "login.html page url",
controller: 'login controller'
}));
不需要编写任何代码appcontroller'。无论何时运行应用程序,url路径都应为空。所以这一行是$stateProvider.otherwise({redirectTo:'/login'})代码>帮助打开登录屏幕。尝试更改app.config部分
app.config(function ($stateProvider) {
$stateProvider.otherwise({ redirectTo: '/login' });
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
}).state('login', {
url: "/login",
templateUrl: "login.html page url",
controller: 'login controller'
}));
不需要编写任何代码appcontroller'。无论何时运行应用程序,url路径都应为空。所以这一行是$stateProvider.otherwise({redirectTo:'/login'})代码>有助于打开登录屏幕。好的,现在我进入登录屏幕。但是$scope.loginModal.hide()有一个错误;TypeError:无法读取未定义的属性“hide”。可以做些什么?导航到下一个屏幕正确吗?好的,现在我进入登录屏幕。但是$scope.loginModal.hide()有一个错误;TypeError:无法读取未定义的属性“hide”。可以做些什么?导航到下一个屏幕正确吗?好的,现在我进入登录屏幕。但是$scope.loginModal.hide()有一个错误;TypeError:无法读取未定义的属性“hide”。可以做些什么?导航到下一个屏幕正确吗?好的,现在我进入登录屏幕。但是$scope.loginModal.hide()有一个错误;TypeError:无法读取未定义的属性“hide”。可以做些什么?导航到下一个屏幕正确吗