Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 不显示Angularjs路由模板_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript 不显示Angularjs路由模板

Javascript 不显示Angularjs路由模板,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我有以下app.js文件: 'use strict'; var app = angular.module('app', [ 'auth0', 'angular-storage', 'angular-jwt', 'ui.router', 'Environment', 'Api', 'Profile' ]); app.config(['$stateProvider', '$urlRouterProvider', function ($s

我有以下
app.js
文件:

'use strict';

var app = angular.module('app', [
    'auth0',
    'angular-storage',
    'angular-jwt',
    'ui.router',
    'Environment',
    'Api',
    'Profile'

]);


app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('main', {
            url: '/main',
            templateUrl: 'js/modules/App/views/frontpage.html'
        })
        .state('login', {
            url: '/login',
            templateUrl: 'js/modules/User/views/login.html',
            controller: 'LoginCtrl'
        });

    $urlRouterProvider
        .otherwise('/main');
}]);


app.config(['authProvider', '$httpProvider', '$locationProvider', 'jwtInterceptorProvider',
    function myAppConfig(authProvider, $httpProvider, $locationProvider, jwtInterceptorProvider) {
        authProvider.init({
            domain: 'marcrasmussen.eu.auth0.com',
            clientID: 'hphpe4JiceMW8FSA02CN7yOYl5fUaULe',
            loginUrl: '/login'
        });

        authProvider.on('loginSuccess', ['$location', 'profilePromise', 'idToken', 'store',
            function ($location, profilePromise, idToken, store) {

                console.log("Login Success");
                profilePromise.then(function (profile) {
                    store.set('profile', profile);
                    store.set('token', idToken);
                });

                $location.path('/');
            }]);

//Called when login fails
        authProvider.on('loginFailure', function () {
            alert("Error");
        });

        //Angular HTTP Interceptor function
        jwtInterceptorProvider.tokenGetter = ['store', function (store) {
            return store.get('token');
        }];
//Push interceptor function to $httpProvider's interceptors
        $httpProvider.interceptors.push('jwtInterceptor');

    }]);

app.run(['auth', function (auth) {
    // This hooks all auth events to check everything as soon as the app starts
    auth.hookEvents();
}]);
angular.module('Profile', [])
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('profile', {
            abstract: true,
            url: '/profile'
        })
        .state('profile.index', {
            url: '/index',
            templateUrl: 'js/modules/Profile/views/viewProfile.html'
        })
}]);
我有以下
profile.js
文件:

'use strict';

var app = angular.module('app', [
    'auth0',
    'angular-storage',
    'angular-jwt',
    'ui.router',
    'Environment',
    'Api',
    'Profile'

]);


app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('main', {
            url: '/main',
            templateUrl: 'js/modules/App/views/frontpage.html'
        })
        .state('login', {
            url: '/login',
            templateUrl: 'js/modules/User/views/login.html',
            controller: 'LoginCtrl'
        });

    $urlRouterProvider
        .otherwise('/main');
}]);


app.config(['authProvider', '$httpProvider', '$locationProvider', 'jwtInterceptorProvider',
    function myAppConfig(authProvider, $httpProvider, $locationProvider, jwtInterceptorProvider) {
        authProvider.init({
            domain: 'marcrasmussen.eu.auth0.com',
            clientID: 'hphpe4JiceMW8FSA02CN7yOYl5fUaULe',
            loginUrl: '/login'
        });

        authProvider.on('loginSuccess', ['$location', 'profilePromise', 'idToken', 'store',
            function ($location, profilePromise, idToken, store) {

                console.log("Login Success");
                profilePromise.then(function (profile) {
                    store.set('profile', profile);
                    store.set('token', idToken);
                });

                $location.path('/');
            }]);

//Called when login fails
        authProvider.on('loginFailure', function () {
            alert("Error");
        });

        //Angular HTTP Interceptor function
        jwtInterceptorProvider.tokenGetter = ['store', function (store) {
            return store.get('token');
        }];
//Push interceptor function to $httpProvider's interceptors
        $httpProvider.interceptors.push('jwtInterceptor');

    }]);

app.run(['auth', function (auth) {
    // This hooks all auth events to check everything as soon as the app starts
    auth.hookEvents();
}]);
angular.module('Profile', [])
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('profile', {
            abstract: true,
            url: '/profile'
        })
        .state('profile.index', {
            url: '/index',
            templateUrl: 'js/modules/Profile/views/viewProfile.html'
        })
}]);
在my
index.html
中,文件如下所示:

<script src="js/modules/Profile/lib/profile.js"></script>
<script src="js/modules/App/lib/app.js"></script>
<script src="js/modules/App/directives/login/login.js"></script>

最后,我当然有我的视图端口:

<div class="main" ui-view>

</div>

正如您所知,我的应用程序是在路径
/main
上启动的,它工作得非常好,
frontpage.html
正在使用该文件中的所有
html
进行渲染

但是,当我转到
profile.index
/profile/index
时,控制台中不会显示错误,模板文件
js/modules/profile/views/viewProfile.html中也不会显示html


谁能告诉我为什么会这样?我做错了什么?

我想问题可能是你的抽象状态。您没有为此状态定义
模板
模板URL
。还要注意,抽象状态的模板必须包含
ui-view
指令,以便其子级填充

您可能需要按照以下思路做一些事情:

    .state('profile', {
        abstract: true,
        url: '/profile',
        template: '<ui-view />
    })
.state('profile'{
摘要:没错,
url:“/profile”,
模板:'
})