【发布时间】:2016-08-17 17:16:44
【问题描述】:
我是 Angular js 的新手,有点难以理解 Angular js 中的路由概念。
我正在开发管理网站。我需要如下结构。
我有 Login.html = 这是单独的页面,而不是部分页面 Signup.html = 这也是单独的页面,而不是部分页面 成功登录后,它将转到仪表板,我将使用 ng-view 加载我的所有部分。
我怎么能这样做?我用谷歌搜索了它。我只能看到部分视图。
我确实喜欢关注,但没有工作。我知道这是错误的,但不知道该怎么做
项目:
app.js
var nApp = angular.module('nApp', ['ngRoute']);
nApp .config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/Login', {
templateUrl: 'App/Login/Login.html',
controller: 'LoginController',
caseInsensitiveMatch:true
}).when('/Signup', {
templateUrl: 'App/Signup/Signup.html',
controller: 'SignupController',
caseInsensitiveMatch:true
}).when('/Dashboard', {
templateUrl: 'App/Index.html',
controller: 'DashboardController',
caseInsensitiveMatch:true
})
.otherwise({
redirectTo: '/Login'
});
}]);
登录.html
<html ng-app="nApp">
<head></head>
<body></body>
</html>
注册.html
<html ng-app="nApp">
<head></head>
<body></body>
</html>
索引.html
<html ng-app="nApp">
<head></head>
<body>
<div ng-view></div>
</body>
</html>
将 app.js 放在 App 目录下 \ 有没有其他方法可以做到这一点,请提及...
【问题讨论】:
-
请提供你的作品JSfiddle。
-
编辑了问题,你能看看这个。我不知道该怎么做。所以我也不能做 JsFiddle。
-
你好像错过了ng-app。
-
不,这不是问题.. 我只是给出了一些覆盖... 不准确。我想知道结构怎么做..
-
如果你看这个,这是三个不同的页面。不偏一个
标签: javascript angularjs