0

Here is the directive:

<a ng-if="field.bindingType == 'options'">
 <select ng-model="field.value" {{html}} >
  <option ng-repeat="(k,v) in field.options" value="{{k}}">{{v}}</option>
 </select>
</a>
<a ng-if="field.bindingType != 'options'">
 <a ng-if="['text','ntext','nvarchar','varchar'].indexOf(field.type) > -1">
  <textarea ng-model="field.value" {{html}} ></textarea>
 </a>
 <a ng-if="['double','float','int'].indexOf(field.type) > -1">
  <input type="number" ng-model="field.value" {{html}} />
 </a>
 <a ng-if="field.type == 'bit'">
  <input type="checkbox" ng-model="field.value" {{html}} />
 </a>
 <a ng-if="field.type == 'date'">
  <input type="date" ng-model="field.value" {{html}} />
 </a>
 <a ng-if="field.type == 'time'">
  <input type="time" ng-model="field.value" {{html}} />
 </a>
 <a ng-if="field.type == 'datetime'">
  <input type="datetime-local" ng-model="field.value" {{html}} />
 </a>
</a>

For some reason, when field.bindingType is 'options', and therefore passes the first ng-if, it can still pass the second ng-if (bindingType is NOT 'options'). Obviously, that's not possible, but it keeps happening.

This only happens when field. type matches one of the inner ng-if conditions, though. It's as if it is ignoring the ng-if="field.bindingType != 'options'" part of the directive.

What's the problem here?

Thanks.

Roham Rafii
  • 2,929
  • 7
  • 35
  • 49
KthProg
  • 2,050
  • 1
  • 24
  • 32
  • huff difficult to read.. Why dont you use template url or worst case you dont have to concat string in js to be able to continue in the next line you can add [multi-line string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings#Multi-line_strings) in javascript with **`\\`** – PSL Jan 14 '15 at 22:25
  • @PSL I cleared up the formatting. – KthProg Jan 14 '15 at 22:34
  • Can you put this in a jsFiddle? Now it looks like you're missing a bunch of quotes. You probably mean ng-if="field.bindingType == 'options'" with quotes, right? – Dan Caddigan Jan 14 '15 at 22:36
  • @DanCaddigan Added quotes. I would have to make a mock-up of the whole thing for a jsfiddle. The actual code is thousands of lines. – KthProg Jan 14 '15 at 22:39
  • Sounds like some tags aren't getting closed. I would inspect the generated markup and make sure your original tag is getting closed. – Dan Caddigan Jan 14 '15 at 22:46
  • @DanCaddigan yeah it looks like Angular isn't closing the tags, but they are closed in the template so obviously that's Angular's problem not mine and really doesn't help solve the problem. – KthProg Jan 29 '15 at 14:15
  • @KthProg either that or your {{html}} is doing something bad. Can you remove the {{html}} to make your example simpler? Any way you could get an example in a jsfiddle? You're way more likely to get your issues resolved with a jsfiddle or a plnkr. – Dan Caddigan Jan 29 '15 at 17:15
  • Someone resurrected this and edited it? lol. Man I hardly remember what I was even working on back then. – KthProg Oct 05 '18 at 15:31

0 Answers0