I have an ng-if
which I know should evaluate to false.. but noticing my directive posSlider
is still being initialized via it's function initValues()
page.html
<div ng-if="bigdata.pieces[index].type == 'pos'" class="control-lock pos-detail-container" >
...
<input type="range" min="0" max="100" value="0" class=" vVertical " ng-model="posValue" pos-slider ng-class="{'vclosed':bigdata.pieces[index].state.meta=='open'}"/>
</div>
Can someone explain what's going on? I thought the ng-if would prevent the directive from initializing until true
directive.js
orion.directive('posSlider', function($ionicGesture, $ionicSlideBoxDelegate, $timeout) {
"use strict";
return {
restrict : 'A',
link : function(scope, elem, attrs, e) {
function initValues() {
if (scope.detail.state.meta === 'open') {
scope.posValue = 0;
}
else if (scope.detail.state.meta === 'closed') {
scope.posValue = 100;
}
}
initValues();
...