Skip to content

Instantly share code, notes, and snippets.

@otarim
Created March 14, 2016 14:29
Show Gist options
  • Select an option

  • Save otarim/50144e5cb2d33d715cdd to your computer and use it in GitHub Desktop.

Select an option

Save otarim/50144e5cb2d33d715cdd to your computer and use it in GitHub Desktop.
.directive('as',function($compile){
return {
restrict: 'E',
// replace: true,
transclude: true,
scope: {},
require: '?ngModel',
controller: function($scope,$compile){
},
link: function(scope, element, attrs, ngModel,linker){
if (!ngModel) return
ngModel.$render = function() {
if (!ngModel.$viewValue) return
var as = ngModel.$viewValue
scope.model = as
var comComileString = '<'+as.type+' model="model"></'+as.type+'>'
var comComile = $compile(comComileString)
element.html(comComile(scope))
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment