Thanks Jacob,
But it does not work.
I applied as:
template:
<input type="text" name="title" data-ng-model="inventory[invName1]"/>

controller.js:
$scope.inventory = { invName1: 'nn' /* all the things */ };

But in browser on inspect element i saw that:
<input type="text" name="title" data-ng-model="inventory[invName]"
class="ng-pristine ng-valid">

And I expect:
<input type="text" name="title" data-ng-model="nn" class="ng-pristine
ng-valid">


On 17 January 2014 12:39, Jacob Biggs <[email protected]> wrote:

> If I understand correctly, then, what you are trying to do with only a
> Controller and a scope variable is impossible.
>
> However, since the string in ng-model is interpreted as plain old
> javascript, you could bind your entire data collection to the scope like:
> $scope.inventory = { invName1: {}, invName2: {} /* all the things */ }
>
> Then, you could reference them in your html as follows:
> <input type="text" ng-model="inventory[invName]" /> // Don't need {{ }}
> anywhere here
>
> I hope this helps!
>
>
> On Thursday, January 16, 2014 11:56:18 PM UTC-7, Pushpendra Kumar wrote:
>
>> Thanks  Jacob for reply.
>> I have covered basics already, I wrote "don't know" because of its matter
>> of having value of ng-model as variable.
>> Please go through this again:
>> controller.js :
>> $scope.name = "invName";
>> now template.html:
>> <input type="text" data-ng-model="{{name}}"/>
>> In browser it should be like:
>> <input type="text" data-ng-model="invName"/>
>> or if i update in controller.js:
>> $scope.name = "contName";
>> then in browser it should be like(on inspect element):
>> <input type="text" data-ng-model="contName"/>
>>
>>
>> Pushpendra
>>
>>
>> On 17 January 2014 11:59, Jacob Biggs <[email protected]> wrote:
>>
>>> Perhaps if you gave us a bit more information about the problem you are
>>> trying to solve, we would be able to better help you out.
>>>
>>> You mentioned you didn't know the syntax for using ng-model, which tells
>>> me you've tried diving into Angular before reading up on it! Oh no!
>>>
>>> Before moving forward with your Angular ventures, check out the tutorial
>>> here: http://docs.angularjs.org/tutorial
>>> Also, watch this series of videos from Egghead.io, which are very
>>> helpful to Angular beginners: https://egghead.io/lessons
>>>
>>>
>>> On Thursday, January 16, 2014 10:47:04 PM UTC-7, Pushpendra Kumar wrote:
>>>>
>>>> Thanks for reply.
>>>> MY problem is different.
>>>> I define it. I want to use a template for multiple modules.
>>>> I am getting metadata from db as well model names for all elements.
>>>> I want :
>>>> controller.js :
>>>> $scope.name = "invName";
>>>> now template.html:
>>>> <input type="text" data-ng-model="{{name}}"/><!-- don't know syntax for
>>>> this {{name}}-->
>>>> In browser it should be like:
>>>> <input type="text" data-ng-model="invName"/>
>>>>
>>>> And want to create form json using angular form tag.
>>>> Please reply.
>>>>
>>>>
>>>>
>>>> Pushpendra
>>>>
>>>> On Friday, 17 January 2014 10:50:53 UTC+5:30, Aadithya Udupa wrote:
>>>>>
>>>>> One updates the ng-model on the view using the $scope object in the
>>>>> controller.
>>>>> Check out this hello world plnkr - http://plnkr.co/edit/dBJmLr?
>>>>> p=preview
>>>>>
>>>>> Whenever you change the  value of $scope.helloMessage, view gets
>>>>> updated automatically.
>>>>> Please let me know if I am missing something.
>>>>>
>>>>>
>>>>> On Fri, Jan 17, 2014 at 10:34 AM, Pushpendra Kumar <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Is there any way to update value of ng-model attribute using
>>>>>> controller's scope object?
>>>>>>
>>>>>>
>>>>>> On Thursday, 16 January 2014 18:46:39 UTC+5:30, Pushpendra Kumar
>>>>>> wrote:
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>>          I am new guy in angular world.
>>>>>>>          I want to set the value of ng-model from controller and
>>>>>>> change this on other actions without using directive.
>>>>>>>          Please help me.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Pushpendra
>>>>>>>
>>>>>>  --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "AngularJS" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at http://groups.google.com/group/angular.
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Aadithya C Udupa
>>>>>
>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "AngularJS" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/angular.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to