【问题标题】:Renedering a twig template from Angularjs从 Angularjs 渲染一个树枝模板
【发布时间】:2018-10-03 08:37:16
【问题描述】:

我正在尝试通过 AngularJs 生成一个模态的树枝模板。但是,我的模式没有出现,它只是要求出现在我的调试工具中的 404 请求(没有找到“GET /en/admin/payments/views/viewServiceStatus”的路由。我不知道是什么问题是。这是角度指令。

app.directive('viewServiceStatus', [function() {
return {
restrict: 'E',
scope: {
  model: '=',
},
link: function(scope, element, attributes) {
  scope.$watch('model.visible', function(newValue) {
    var modalElement = element.find('.modal');
    modalElement.modal(newValue ? 'show' : 'hide');
  });

  element.on('shown.bs.modal', function() {
    scope.$apply(function() {
      scope.model.visible = true;
    });
  });

  element.on('hidden.bs.modal', function() {
    scope.$apply(function() {
      scope.model.visible = false;
    });
  });

},
templateUrl: 'views/viewServiceStatus',
 };
}]);

这是我的 route.yaml 文件

acme_bundle_service_status:
path: views/viewServiceStatus
defaults:
    _controller: FrameworkBundle:Template:template
    template:    '@PaymentBundle/Resources/views/Admin/Payment/viewServiceStatus.html.twig'

【问题讨论】:

  • @brokleyscoding 您应该能够在调试工具的Network 控制台中看到失败的请求。它调用哪条路径?我会假设myappsdomain.com/app_dev.php/views/viewServiceStatus...
  • 是的,这是路径,我的意思是这个错误出现在我的调试工具中。
  • 试试templateUrl: '/views/viewServiceStatus',

标签: php angularjs symfony twig


【解决方案1】:

试试

`templateUrl: '/views/viewServiceStatus',`

而不是

`templateUrl: 'views/viewServiceStatus',`

希望有帮助

【讨论】:

    猜你喜欢
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-09
    相关资源
    最近更新 更多