【发布时间】:2017-05-13 10:41:08
【问题描述】:
在 chrome 中 - 两种 变体都有效。但是,在模拟 ios 时 - 使用 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 模拟器中都可以正常工作。例如,当使用 ui 路由器时 - 我能够毫无问题地加载外部模板:
$stateProvider.state('app.dashboard', {
url: "/dashboard",
views: {
'menuContent': {
templateUrl: '../template/dashboard.ng.html',
controller: 'DigstackDashboard'
}
}
});
我的问题是 - 在指令的情况下,为什么 templateUrl 值不能只在 ios 模拟器中工作?
【问题讨论】:
-
我会更新我的问题 - ApiEndpoint 是一个常量
-
请告诉我
listitems.ng.html的整个路径 -
[app]/www/templates/listitems.ng.html 请注意,此路径在浏览器中渲染时可以正常工作 - 并且在使用 ui-router 时也是如此。只是没有指令。
-
您使用哪个服务器来运行应用程序?
-
我正在运行 gulp remove-proxy && ionic emulate ios --target="iPhone-5" 来启动模拟器。我正在使用 vagrant 运行我的服务 - 并修改了我的 /etc/hosts 文件以接受来自配置域的流量。
标签: angularjs ionic-framework angularjs-directive