0

Is there a way to use javascript to apply the ng-model directive to a created element? In the code below, I want the new select element to be bound using ng-model to a scoped variable inside the controller:

angular.module('myApp').directive('dynamicHtml', function ($q, $http, $compile) {
    return {
        restrict: 'EAC',
        scope: '=',
        compile: function(element, attr) {
              return function(scope, element, attr) {

              var select = document.createElement('select');
              // Here I want to use javascript to apply ng-model='controllerVar' 
              // to the new select element
              element.append(select);
             }
    }
};
});

1 Answer 1

0

Whoops - my apologies...I forgot to compile the thing...carry on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.