【问题标题】:angularjs ng-route. not work templateUrlangularjs ng-route。不工作模板网址
【发布时间】:2017-10-18 07:15:00
【问题描述】:

它不适用于指定的templateUrl:test.html,但如果您指定模板则可以:'Hello'

工作

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文件的路径中有一个符号!

链接

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

我正在使用 nw.js

【问题讨论】:

标签: angularjs nw.js angularjs-ng-route


【解决方案1】:

您可以尝试为您的模板网址添加路径

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-07
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 2013-06-09
    • 2016-06-19
    • 2017-06-08
    • 2015-12-12
    相关资源
    最近更新 更多