2016-12-29 69 views
0

在chrome中 - 兩個變體都有效。但是,在模擬ios時 - 使用templateUrl的指令確實不是的工作。Angular指令不能在離散應用程序中使用templateUrl進行渲染

不會在IOS模擬器工作,但確實在瀏覽器中工作:

angular.directive('listitems', function(ApiEndpoint) { 
    return { 
    restrict: 'A', 
    templateUrl: '../template/listitems.ng.html', 
    scope: true 
    }; 
}) 

作品在IOS模擬器並在瀏覽器工作:

angular.directive('listitems', function(ApiEndpoint) { 
    return { 
    restrict: 'A', 
    template: '<strong>listitems</strong>', 
    scope: true 
    }; 
}) 

在別處使用templateUrl在瀏覽器和ios模擬器中都能很好地工作。使用例如,當用戶界面路由器 - 我能夠加載外部模板沒有問題:

$stateProvider.state('app.dashboard', { 
    url: "/dashboard", 
    views: { 
    'menuContent': { 
     templateUrl: '../template/dashboard.ng.html', 
     controller: 'DigstackDashboard' 
    } 
    } 
}); 

我的問題是 - 在該指令的情況下,爲什麼會在templateUrl價值不僅在IOS模擬器工作?

+0

我會更新我的問題 - ApiEndpoint是一個常量 –

+0

請告訴我'listitems.ng.html'的整個路徑 –

+0

[app] /www/templates/listitems.ng.html請注意,此路徑工作正常在瀏覽器中渲染時 - 以及使用ui-router時。只是沒有指示。 –

回答

0

發現問題!我希望這會幫助別人。

angular.config(function($sceDelegateProvider){ 
    $sceDelegateProvider.resourceUrlWhitelist([ 
     'self', 
     'https://www.example.com/**' 
    ]); 
} 

即使在uirouter中 - 這似乎並不需要。在ios模擬器中 - 需要此配置才能加載模板。

相關問題