MegaPowerRockstar Posted October 4, 2018 Report Posted October 4, 2018 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 Quote
MegaPowerRockstar Posted October 4, 2018 Author Report Posted October 4, 2018 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 ? Quote
Gowtham7777 Posted October 4, 2018 Report Posted October 4, 2018 <li *ngFor="let user of users ; index as i; "> {{i}}/{{users.length}}. {{user}} </li> Quote
hotlantian Posted October 4, 2018 Report Posted October 4, 2018 5 minutes ago, Gowtham7777 said: <li *ngFor="let user of users ; index as i; "> {{i}}/{{users.length}}. {{user}} </li> This syntax does not work in old angular Quote
Gowtham7777 Posted October 4, 2018 Report Posted October 4, 2018 matter ardam ayithe challu, syntax di emm vundi bro.... Quote
Paidithalli Posted October 4, 2018 Report Posted October 4, 2018 nenu angular vadi years avthundhi.. but scope lo petti cheyyochankunta. scope:{ name: '@', error: '@' }, otherwise, you can try with ng-if ? Quote
MegaPowerRockstar Posted October 5, 2018 Author Report Posted October 5, 2018 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. Quote
MegaPowerRockstar Posted October 5, 2018 Author Report Posted October 5, 2018 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.. Quote
Kalam_Youtheman Posted October 5, 2018 Report Posted October 5, 2018 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 Quote
MegaPowerRockstar Posted October 5, 2018 Author Report Posted October 5, 2018 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... Quote
Kalam_Youtheman Posted October 5, 2018 Report Posted October 5, 2018 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.