Angularjs在Laravel 5中的表单动作属性内插值
我了解到,在Laravel中的Angular代码前面添加@,效果很好。i、 e:Angularjs在Laravel 5中的表单动作属性内插值,angularjs,laravel,laravel-5,Angularjs,Laravel,Laravel 5,我了解到,在Laravel中的Angular代码前面添加@,效果很好。i、 e:你好,@{{yourName} 我的Angularjs ng repeat正在生成不同的表单和HREF。插值适用于链接,但不适用于表单动作属性内部 我想生成与此类似的链接: http://www.example.com/clients/5/edit 这很有效 <a class="btn" href="{{ URL::to('clients/') }}/@{{ i.clientid }}/edit">Ed
你好,@{{yourName}代码>
我的Angularjs ng repeat正在生成不同的表单和HREF。插值适用于链接,但不适用于表单动作属性内部
我想生成与此类似的链接:
http://www.example.com/clients/5/edit
这很有效
<a class="btn" href="{{ URL::to('clients/') }}/@{{ i.clientid }}/edit">Edit</a>
带有两个示例表单的HTML(Laravel blade)
<div ng-app="instantsearch">
<div ng-controller="instantSearchCtrl">
<div class="row">
<div class="col-sm-12">
<input type="text" class="search" ng-model="searchString" placeholder="Enter your search terms" />
</div>
</div>
<div class="row data-ctrl" ng-repeat="i in items | filter:searchString | limitTo:20 ">
<div class="col-sm-8">
@{{ i.first_name }} @{{ i.last_name }} @{{ i.address }}
</div>
<div class="col-sm-4">
<!-- TEST FORM #1 -->
{!! Form::open(array('url' => 'clients/@{{ i.clientid }}' , 'class' => 'pull-right', 'onsubmit' => 'return ConfirmDelete()')) !!}
{!! Form::hidden('_method', 'DELETE') !!}
{!! Form::button('', array('type' => 'submit', 'class' => 'btn btn-warning glyphicon glyphicon-trash')) !!}
{!! Form::close() !!}
<!-- TEST FORM #2 -->
<form action="{{ URL::to('clients/') }}/@{{ i.clientid }}" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button>Delete User</button>
</form>
<a class="btn btn-small btn-info pull-right glyphicon glyphicon-pencil" href="{{ URL::to('clients/') }}/@{{ i.clientid }}/edit"></a>
<a class="btn btn-small btn-success pull-right glyphicon glyphicon-list-alt" href="{{ URL::to('clients/') }}/@{{ i.clientid }}"></a>
</div>
</div>
</div>
</div>
@{{i.first_name}}{{i.last_name}}}{{i.address}}
{!!Form::open(数组('url'=>'clients/@{{i.clientid}}','class'=>'向右拉','onsubmit'=>'返回ConfirmDelete()'))
{!!Form::hidden('u method','DELETE')
{!!Form::button(“”,array('type'=>'submit','class'=>'btn-btn-warning-glyphion-glyphion-trash'))
{!!Form::close()!!}
删除用户
添加angularjs变量之前生成的代码
<!-- TEST FORM #1 -->
<form method="POST" action="/public/clients" accept-charset="UTF-8" class="pull-right" onsubmit="return ConfirmDelete()"><input name="_token" type="hidden" value="hkjrehkgjehjk">
<input name="_method" type="hidden" value="DELETE">
<button type="submit" class="btn btn-warning glyphicon glyphicon-trash"></button>
</form>
<!-- TEST FORM #2 -->
<form action="/public/clients" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="hkjrehkgjehjk">
<button>Delete User</button>
</form>
<a class="btn btn-small btn-info pull-right glyphicon glyphicon-pencil" href="/public/clients/{{ i.clientid }}/edit"></a>
<a class="btn btn-small btn-success pull-right glyphicon glyphicon-list-alt" href="/public/clients/{{ i.clientid }}"></a>
删除用户
将angularjs变量添加到表单后生成的代码-表单未显示并获取“Error:[$interpolate:noconcat]Error while Interpolation”错误
删除用户
不能在操作中使用多个表达式(也适用于:src、ng src)
尝试使用ng init设置路径,然后在操作中使用它。大概是这样的:
<form ng-init=\"myPath = '{{ URL::to("clients/") }}/'+ i.clientid + '/edit' \" action="{{myPath}}">
作为建议,不要将angular与后端混用。从来没有。在一个单独的项目中完成你的任务。以后你会感谢我的,这与拉威尔无关。正如错误所说,Angular的“严格上下文转义”不允许您在操作
中使用{{}}
标记。我刚刚在我的项目中对其进行了测试,效果良好。给我们看看你的角度控制器和刀片模板。@JesusRodriguez我完全理解你的意思,快去吧fix@JosephSilberohhhh好吧,奇怪的是它能为A HREF工作。谢谢!虽然我在控制台中收到以下消息,但似乎可以正常工作:错误:[$parse:lexerr]Lexer错误:表达式[\“myPath]@user3489502:\“escape是用于php的(为blade更新此内容),在前端删除此内容($parse使用的angular expresson lexer正在查找\as起始字符,因此它有错误),此外,还有另一个错误{{URL::to(“clients/”}}}}}/=>应该是{{URL::to(“clients/”)}/“.非常感谢!这一行做到了:
。删除了转义的反斜杠,添加了@in action以在Laravel中使用Angularjs变量,并添加了method=“POST”
<!-- TEST FORM #1 -->
<form method="POST" action="/public/clients" accept-charset="UTF-8" class="pull-right" onsubmit="return ConfirmDelete()"><input name="_token" type="hidden" value="hkjrehkgjehjk">
<input name="_method" type="hidden" value="DELETE">
<button type="submit" class="btn btn-warning glyphicon glyphicon-trash"></button>
</form>
<!-- TEST FORM #2 -->
<form action="/public/clients" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="hkjrehkgjehjk">
<button>Delete User</button>
</form>
<a class="btn btn-small btn-info pull-right glyphicon glyphicon-pencil" href="/public/clients/{{ i.clientid }}/edit"></a>
<a class="btn btn-small btn-success pull-right glyphicon glyphicon-list-alt" href="/public/clients/{{ i.clientid }}"></a>
<!-- TEST FORM #1 -->
<form method="POST" action="/public/clients/{{ i.clientid }}" accept-charset="UTF-8" class="pull-right" onsubmit="return ConfirmDelete()"><input name="_token" type="hidden" value="hkjrehkgjehjk">
<input name="_method" type="hidden" value="DELETE">
<button type="submit" class="btn btn-warning glyphicon glyphicon-trash"></button>
</form>
<!-- TEST FORM #2 -->
<form action="/public/clients/{{ i.clientid }}" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="hkjrehkgjehjk">
<button>Delete User</button>
</form>
<a class="btn btn-small btn-info pull-right glyphicon glyphicon-pencil" href="/public/clients/{{ i.clientid }}/edit"></a>
<a class="btn btn-small btn-success pull-right glyphicon glyphicon-list-alt" href="/public/clients/{{ i.clientid }}"></a>
<form ng-init=\"myPath = '{{ URL::to("clients/") }}/'+ i.clientid + '/edit' \" action="{{myPath}}">