php - 从 Angularjs 渲染 Twig 模板

标签 php angularjs symfony twig

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

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'

最佳答案

尝试使用

`templateUrl: '/views/viewServiceStatus',`

而不是

`templateUrl: 'views/viewServiceStatus',`

希望这有帮助

关于php - 从 Angularjs 渲染 Twig 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52622957/

相关文章:

php - 循环中的语法 '${$key} = $val' 在 PHP 中是什么意思?

php - 如何测试序列化变量?如果字符串未序列化,则不会抛出 E_NOTICE

php - 如何对CodeIgniter和MySql表中调查的房屋数量进行求和

javascript - 在解决下一个之前解决 $q.all 中每个 promise 的整个链

javascript - AngularJS 在指令模板中使用 Canvas

mysql - 如何在 Twig 文件中显示行计数结果

php - Sphinx 结果在空格后不返回匹配项

javascript - Symfony - 在外部 JS 文件中创建路由

mysql - SQLSTATE[28000] [1045] 拒绝用户 'root' @'localhost' 的访问(使用密码 : YES) Symfony2

angularjs - 如何从指令链接功能更新 AngularJS 模型?