Forum

Thread tagged as: Question, Forms

AngularJS and Perch forms

Is there anyway I can use angular tags within perch_forms?

Perch_forms at the moment strips all the ng tags (ng-class, ng-model etc)

That is, unless I am missing something.

Damon Golding

Damon Golding 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you give an example of these tags? I'm not familiar with Angular.

Sure thing:

<perch:input class="normal-css-classes" type="text" name="fname" id="fname" label="First name" ng-class="{ 'error' : form.fname.$touched && form.fname.$invalid }" ng-model="user.fname" required />

Most (if not all) angular tags start with ng-. Once processed both ng-model and ng-class are removed.

At the moment I'm having to remove the perch input tags (once processed) and then replace them using Angular.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, ok, attributes rather than tags. Are those actually valid HTML?

Sorry my bad on all accounts.

It seems you can use data-ng- so it validates and as an added bonus to being valid HTML perch doesn't remove them.

The only issue I'm finding is that the conditionals are being turned to html & === &amp;

I can't seem to get perch to ignore the ampersands.

Such a shame. I really thought I had cracked it :(

Drew McLellan

Drew McLellan 2638 points
Perch Support

Those ampersands need to be encoded as the ampersand is a special character in HTML.