Im trying to execute a like POST request with a in angular. The url gets filled in correctly as you can see
<a href="http://dressfriends.app/en/like/product/1006" target="_parent" df-like-product="" class="icon-like trigger animated v-a-m active" data-id="1006" data-type="product" ng-class="{active:product.liked_by_user}"></a>
In the code it looks like this
<a href="##product.like_url##" target="_parent" df-like-product class="icon-like trigger animated v-a-m" data-id="##product.id##" data-type="product" ng-class="{active:product.liked_by_user}"></a>
But everytime it gives a 405 method not allowed ( http://dressfriends.app)并返回http://dressfriends.app
我在没有角度的情况下使用PHP完全相同,这是有效的
<a href="{{ $product->present()->likeUrl }}" df-like-product class="icon-like trigger animated v-a-m {{ ($currentUser and $product->hasLiked($currentUser->id)) ? 'active' : '' }}" data-id="{{ $product->id }}" data-type="product"></a>
&#13;
有人有想法吗?
答案 0 :(得分:0)
Angular不是PHP。为了解决这个问题。你需要使用一些服务。最受欢迎的是$ http和$ resource。
如果您选择$ http服务,则需要制作
somefile.html中的在控制器中你会有这样的东西:
$ scope.someFunction = function(){
$ http.post(url,data,config) 。然后( 功能(响应){ //成功回调 }, 功能(响应){ //失败回调 } ); }
我建议你尝试找一下这方面的教程:
https://docs.angularjs.org/api/ng/service/ $ HTTP
https://www.sitepoint.com/creating-crud-app-minutes-angulars-resource/ ...