AngularJS ngIf prevents finding element
by Jacopo Sabbatini
HTML
<script src="http://code.angularjs.org/1.2.7/angular.js"></script>
<column column="{title: 'Test'}"></column>
JavaScript
var myApp = angular.module('myApp', []);
myApp.directive('column', function () {
return {
template: '<div class="column"><div>{{ column.title }}</div><editor ng-if="editing"></editor></div>',
restrict: 'E',
scope: {
column: '='
},
controller: ['$scope', function ($scope) {
$scope.editing = true;
$scope.toggleEditing = function () {
$scope.editing = !$scope.editing;
};
}],
};
});
myApp.directive('editor', function () {
return {
template: '<form name="columnForm" role="form"><select></select></form>',
restrict: 'E',
link: function postLink(scope, element) {
var select = element.find('select');
console.log(select); // See if it can find the select element
}
};
});