javascript - Why angular doen't get value of ng-models of inputs, html inserted by $sce.trustAsHtml? -


i have code on controller:

angular.module('reporteadorapp')     .controller('sidebarctrl', ['$scope', '$http', '$cookies', '$sce', function ($scope, $http, $cookies, $sce) {         $scope.codecontroles = '<div class="row"><div class="col-sm-12">'         $scope.codecontroles += '<div class="form form-group"><label>' + asignarlistacontroles.nombrecontrol + '</label><select class="form form-control" ng-model="' + asignarlistacontroles.variable1 + '"></select></div>';         $scope.codecontroles += '</div></div>';         $scope.codigohtml = $sce.trustashtml($scope.codecontroles); }]); 

then in html:

<div ng-bind-html="codigohtml"></div> 

i'm trying values of ng-models inserted on view, can't, angular returns undefinided. whats problem?!. if add input manually , assign ng -model, can value.

also can not add data select using ng-repeat

thanks

finally resolve problem this:

var htmltoinsert = $compile('<div>' + $scope.codecontroles + '</div>')($scope); $('#yourdivname').html(htmltoinsert); 

then in html:

<div id="yourdivname"></div> 

;)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -