角度视图没有加载

时间:2017-12-14 17:00:08

标签: angularjs node.js angular-routing

我是节点和角度的菜鸟,我正在尝试使用几页来构建和应用。我已经按照教程确切的点,无论出于何种原因,我的应用程序无法正常工作,也不会加载我的观点。它渲染index.html页面就好了,但当我转到其中一个URL时,它没有将我的视图显示到ng-view div中。任何帮助表示赞赏

以下是我的控制台在登录Url时的样子 enter image description here

server.js

<html lang="en" ng-app="myApp">
    <head>
        <base href="/">
      <meta charset="utf-8">
      <title>ITSC</title>

      <script src="./angular/angular.js"></script>
      <script src="./angular/angular-route.js"></script>
      <script src="./app.js"></script>
    </head>
    <body>
            <a href="#/login">login</a>
        <div ng-view></div>

        <script src="./controllers/position.js"></script>
    </body>
    </html>

的index.html

<div class="container login">
<div class="panel">
    <div class="panel-body">
        <form>
            <div class="form-group">
                <label>Email</label>
                <input type="email" name="email" id="email" placeholder="email@website.com" class="form-control">
            </div>
            <div class="form-group">
                <label>Password</label>
                <input type="password" name="password" id="password" placeholder="Password" class="form-control">
                <button type="submit">Log in</button>
            </div>
        </form>
    </div>
</div>
</div>

的login.html

angular.module('myApp', ['ngRoute'])
.config(function($routeProvider, $locationProvider){
    $routeProvider
    .when('/',{
        templateURL:'partials/apply.html'
    })
    .when('/login',{
        templateURL:'partials/login.html'
    })
    .when('/managers',{
        templateURL:'partials/managers.html'
    })
    .otherwise({
        redirectTo:'partials/apply.html'
    });
    $locationProvider.html5Mode(true);
});

app.js

with

1 个答案:

答案 0 :(得分:0)

您需要声明一些控制器,例如:

data["duration"] = data['end_date'] - data['start_date']