Im trying to create a link in a view of AngularJS application just to send a data-method DELETE.
My route:
app.delete('/logout', function(req, res) {
req.session = null
res.status(200)
res.redirect('/')
})
My PugJS template:
a(ng-href='/logout', data-method='delete', data-confirm='Are you sure?', rel='nofollow')
span(translate) Logout
The HTML generated:
<a ng-href="/logout" data-method="delete" data-confirm="Are you sure?" rel="nofollow" class="" href="/logout">
<span translate="translate" class="ng-scope">
<span class="ng-scope">Logout</span>
</span>
</a>
But when I follow the link I receive the follow message:
Cannot GET /logout
It's looks to me that the data-method isn`t working. Does some one know what is happening?
Thanks for while.
I suppose you are used to use data-method
with Rails. In AngularJS (or HTML), there is no such thing as data-method
.
My suggestion is to either write your own directive to send the delete, or to add an action in your controller and use ng-click
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With