Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use laravel partial view by angular js in templateURL

I want to show a laravel blade view file in angular JS directive by

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

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

I want to use it by angular directive instead of @include('comments.comment-form') Where is my problem? How to solve this. Thank you.

like image 989
Iftakharul Alam Avatar asked Apr 14 '15 06:04

Iftakharul Alam


1 Answers

First you must define a route in laravel

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

Then you can use it in AngularJS

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

commentsApp.directive('commentForm', function() {
    return {
        restrict: 'EA',
        replace: 'true',
        templateURL: 'comment-form'
    }
});
like image 89
Dimi Mikadze Avatar answered Oct 20 '22 01:10

Dimi Mikadze