How can I add the value of the emberjs variable to an object to my href anchor tag?
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");
}.property("App.adminController.selectionMenu)
});
For this example, I created a fiddle .
+7
source to share