I've created a custom directive in AngularJS. In the link function I'm adding the ng-model and ng-options attributes to the inner template, but, unfortunately the binding doesn't work. But when I place the inner template as is into my html file all works well.
application.directive("customSelect", function () {
var directive = {
restrict: 'E',
template: '<select name="ArrDeplocation" class="arrdepSelect"></select>',
link: function (scope, elem, attr) {
console.log('scope: ', scope);
console.log('element: ', elem);
console.log('attribute: ', attr);
$(elem.children()[0]).attr('ng-model', 'model.selectedCity');
$(elem.children()[0]).attr('ng-options', 'city for city in model.cities');
$(elem.children()[0]).selectmenu();
}
};
return directive;
});