2017-10-18 6 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' 
    // }); 
}); 

'こんにちは'

WORKは

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

あなたは – jitender

+0

がこれを参照してくださいあなたのtest.htmlというファイルを置くフォルダ構造を示し、テンプレートのURLへのパスを入れて試みることができますhttps://stackoverflow.com/questions/40635098/angularjs-routing-with-templateurl –

答えて

1

あなたは

.when('/test', { 
    templateUrl: './test.html', 
    controller: 'ctrl' 
    }) 
関連する問題