Jump to content

Angular JS help needed


MegaPowerRockstar

Recommended Posts

Hi,
I need small help with angular.
I have one input control in a ng-repeat, below is the html content

<form name="vm.itemsForm">
<div id="item{{i.id}}" ng-repeat="i in vm.items">
	<div>
		<p>list your item number</p>
		<input ng-model="vm.item.newItem[i.id].itemNo" type="text" name="itemNo{{i.id}}" placeholder="enter item number" id="itemNo{{i.id}}" required />
		<form-valid ng-show="vm.itemsForm.itemNo.$valid"></form-valid>
		<form-invalid ng-show="vm.itemsForm.itemNo.$touched && vm.itemsForm.itemNo.$invalid"></form-invalid>
		<div ng-messages="vm.itemsForm.itemNo.$error" ng-show="vm.itemsForm.itemNo.$touched">
			<p class="validation-message" ng-message="required">Please enter item number</p>
		</div>
	</div>
</div>
</form>

My issue is for form invalid tag, ng-show value needs to be generated dynamically based on i from ng-repeat because the name of the control i am giving has the iteration value (i.id)
It should be something like
 

<form-valid ng-show="vm.itemsForm.itemNo0.$valid"></form-valid>
<form-invalid ng-show="vm.itemsForm.itemNo0.$touched && vm.itemsForm.itemNo0.$invalid"></form-invalid>
<div ng-messages="vm.itemsForm.itemNo0.$error" ng-show="vm.itemsForm.itemNo0.$touched">
  <p class="validation-message" ng-message="required">Please enter item number</p>
</div>

I tried using {{i.id}} --> gives me syntax error
 

<form-valid ng-show="vm.itemsForm.itemNo{{i.id}}.$valid"></form-valid>

 

Can someone please help me how i should read that value into those form tags

Link to comment
Share on other sites

3 minutes ago, Gowtham7777 said:

try index bro.

show me sample code please .. as i said {{}} using this gives syntax error.. index also how do i read it ?

 

Link to comment
Share on other sites

16 hours ago, Gowtham7777 said:

<li *ngFor="let user of users ; index as i; ">

 

{{i}}/{{users.length}}. {{user}} </li>

Did you read my complete message ? 
I need to evaluate the expression in ng-show only, not on a control item.
On my custom html control, i need to use ng-show.

Please read it completely.. i have mentioned very much clear.

Link to comment
Share on other sites

15 hours ago, Paidithalli said:

nenu angular  vadi years avthundhi.. but scope lo petti cheyyochankunta.

scope:{ name: '@', error: '@' },

otherwise, you can try with ng-if ?

pls give me solution to the context... 
My custom control are field validators, if you select the control and go away without entering text then it will raise the error..
The control id/name is generated dynamically, so i need to use it dynamically..

 

Link to comment
Share on other sites

17 minutes ago, MegaPowerRockstar said:

Did you read my complete message ? 
I need to evaluate the expression in ng-show only, not on a control item.
On my custom html control, i need to use ng-show.

Please read it completely.. i have mentioned very much clear.

ala ante uppu kaaram thineevaadu hurt avthaaaduu bro... neeku solution raaadhu... nee pani kabbattii u need to have lil patience if some1 tryin to help

Link to comment
Share on other sites

42 minutes ago, Kalam_Youtheman said:

ala ante uppu kaaram thineevaadu hurt avthaaaduu bro... neeku solution raaadhu... nee pani kabbattii u need to have lil patience if some1 tryin to help

Ikkada patience problem kadhu... we both will be wasting time in explaining things.... 

I have patience to explain but it would just delay time... 

Link to comment
Share on other sites

27 minutes ago, MegaPowerRockstar said:

Ikkada patience problem kadhu... we both will be wasting time in explaining things.... 

I have patience to explain but it would just delay time... 

not a good place to test your patience here.. anyway hope you get soltn soon 

good lcuk

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...