angularjs - 我如何在templateURL中使用Angular JS使用Laravel局部 View

标签 angularjs laravel-5

我想在Angular JS指令中显示laravel Blade View 文件

var commentsApp = angular.module('CommentApp',[]);

commentsApp.directive('commentForm',function(){
    return {
        restrict: 'EA',
        replace: 'true'
        templateURL: 'views/comments/comment-form.blade.php'
    }
});

我想通过 Angular 指令而不是使用@include('comments.comment-form')我的问题在哪里?如何解决这个问题。
谢谢你。

最佳答案

首先,您必须在laravel中定义一条路线

Route::get('comment-form', function() {
    return view('comments.comment-form');
});

然后您可以在AngularJS中使用它
var commentsApp = angular.module('CommentApp', []);

commentsApp.directive('commentForm', function() {
    return {
        restrict: 'EA',
        replace: 'true',
        templateURL: 'comment-form'
    }
});

关于angularjs - 我如何在templateURL中使用Angular JS使用Laravel局部 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29621048/

相关文章:

javascript - 无法将服务注入(inject) Controller

javascript - 在执行代码之前等待 promise 解决

php - 关系中使用的 Laravel Eloquent 和 Trimming 字段

php - 如何在 Laravel 5 中对多个表使用身份验证

Laravel 5 - 使用 'old' 预填充表单

javascript - 替换 JavaScript 对象中的值中的字符串

javascript - 如何使用 Angular-js 验证图像文件

Laravel 5.2 身份验证更改 'users' 表

php - 加入3张表

javascript - 无法发送包含特殊字符的密码(用空格代替)