Monday, October 24, 2022

Laravel Blade @include .html files | Laravel Blade Highlight Change Tags when use AngularJS along with Laravel

I am going to use AngularJS along with Laravel, and I wanted to change Laravel tags to [[ ]], it can achived by below codes:

Blade::setContentTags('[[', ']]'); // for variables and all things Blade

Blade::setEscapedContentTags('[[[', ']]]'); // for escaped data
But my solution is to have Angular and Blade works very simple, I create a another xxx.php every time instead of xxx.blade.php. I need some Angular and name this partial just '.php' and not '.blade.php'.

Lets say I have a user create form named "create.blade.php" inside "views/user" directory using below content:

@extends('layouts.user')
@section('content')
    <form>
        <h2>Create User</h2>
        @include('user.createBody');
    </form>
@endsection

Now I will create an php file named "createBody.php" inside "views/user" directory and put some html there:

<div class="row">
    <h1>User Name={{userName}}</h1>
    <div class="col-lg-4 col-sm-6">
        <label>Name</label>
        <input type="text" class="form-control" ng-model="userName">
    </div>
    <div class="col-lg-4 col-sm-6">
        <label>ID</label>
        <input type="text" class="form-control">
    </div>
</div>

So here we can use {{ }} tags both in Laravel and AngularJS

No comments:

Post a Comment