2017-10-18 90 views
1

它不與指定templateUrl工作:test.html的,但工作,如果你指定的模板: '你好'angularjs ng-route。不行templateUrl

工作

app.config(function($routeProvider){ 
    $routeProvider 
    .when('/test', { 
     template: '<h1>home</h1>', 
     controller: 'ctrl' 
    }) 

    // .otherwise({ 
    // redirectTo: '/home', 
    // controller: 'ProductCtrl' 
    // }); 
}); 

不起作用

app.config(function($routeProvider){ 
    $routeProvider 
    .when('/test', { 
     templateUrl: 'test.html', 
     controller: 'ctrl' 
    }) 

    // .otherwise({ 
    // redirectTo: '/home', 
    // controller: 'ProductCtrl' 
    // }); 
}); 

我有一個標誌!在文件的路徑是#!/test

LINK

<a style="color:white;" href="#!/test">Go</a> 

我使用nw.js

+1

顯示,你把你的test.html文件 – jitender

+0

參考這個文件夾結構https://stackoverflow.com/questions/40635098/angularjs-routing-with-templateurl –

回答

1

你可以嘗試把一個路徑到您的模板網址

.when('/test', { 
    templateUrl: './test.html', 
    controller: 'ctrl' 
    })