使用Angular.js渲染局部视图时获取空白页面

时间:2016-08-02 11:34:10

标签: javascript angularjs angular-ui-router

我需要帮助。我在Angular.js中使用ui-router渲染局部视图时得到空白页面。我的代码如下。

<!DOCTYPE html>
<html lang="en" ng-app="Spesh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Chinmaya Sahu">
    <title>...:::WELCOME TO Spesh:::...</title>
    <script src="js/pace.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="js/angularjs.js" type="text/javascript"></script>
    <script src="js/angularuirouter.js" type="text/javascript"></script>
    <script src="js/loginRoute.js" type="text/javascript"></script>
</head>

<body>
<div  ui-view>

</div>
<script src="controller/loginController.js"></script>
<script src="js/default.js"></script>
<script src="controller/dashboardController.js"></script>
</body>
</html>
  

loginRoute.js:

var Dahboard=angular.module('Spesh',['ui.router']);
Dahboard.run(function($rootScope, $state) {
      $rootScope.$state = $state;
 });
Dahboard.config(function($stateProvider, $urlRouterProvider,$locationProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider
     .state('/', { /*....This state defines All type of user login...*/
            url: '/',
            templateUrl: 'dashboardview/login.html',
            controller: 'loginController'
        })
     .state('dashboard', { /*....This state defines All type of user login...*/
            url: '/dash',
            templateUrl: 'dashboardview/dashboard.html',
            controller: 'dashboardController'
     })
})

上面的页面是我的配置页面。最初我需要将login.html页面呈现为索引页面但它即将闪烁。请帮助我。

1 个答案:

答案 0 :(得分:0)

检查您的templateUrl并将javascript文件放在div标签

下面