Cannot use "ng-attr-ng-model"

72 views
Skip to first unread message

DaAwesomeP

unread,
Apr 12, 2015, 5:05:20 PM4/12/15
to ang...@googlegroups.com
I want to use {{}} in ng-model, so I trying to use the following:
<input ng-attr-ng-model="$object.{{name}}">
However, it doesn't work. It simply stays as {{name}}. There is no substitution. If I use ng-attr- with any other attribute, then it works fine. It seems that ng-model doesn't want to do it.

Majid Burney

unread,
Apr 13, 2015, 4:32:13 AM4/13/15
to ang...@googlegroups.com
The ngAttr directive is intended to create dynamic attribute values without incidentally creating invalid markup — not to be used for other directives. It's explained here: https://docs.angularjs.org/guide/directive#-ngattr-attribute-bindings

I'd suggest explaining what you want to accomplish, and someone here will probably be able to help point you in another direction.

Sander Elias

unread,
Apr 13, 2015, 4:57:06 AM4/13/15
to ang...@googlegroups.com

Hi,

You can’t use interpolation in ngModel, and you don’t need to.
use do this instead:

<input ng-model="$object[name]">

Does that help?

Regards
Sander

DaAwesomeP

unread,
Apr 13, 2015, 11:01:05 PM4/13/15
to ang...@googlegroups.com
Thanks! I didn't realize that.
Reply all
Reply to author
Forward
0 new messages