How can I add the value of the emberjs variable to an object to my href anchor tag?

I need something like below

<a href="/Admin/MenuEdit/{{ResAdmin.adminController.selectionMenu}}">Edit Selected Menu</a>


selectionMenu is a variable in the ResAdmin.adminController

Ember Object.


source to share

1 answer

To declare a binding for an attribute, you need to use bindAttr

. You can use this helper to bind an attribute to either a global path or a variable in the current context such as your view.

For example, you might have a template like this:

<a {{bindAttr href="menuUrl"}}>Edit Selected Menu</a>


Which is bound to a property in your view, for example:

App.MyView = Ember.View.extend({
    menuUrl: function() {
        return "/Admin/MenuEdit/" + this.get("App.adminController.selectionMenu");


For this example, I created a fiddle .   



All Articles