Ng-model not working for attribute directive

后端 未结 1 872
后悔当初
后悔当初 2021-01-29 01:15

I have a simple controller:

.controller(\"TestController\",[\'$scope\', function($scope) {
    this.p = {};
    this.p.name = \"Foo\";
    this.p.surname = \"Bar         


        
1条回答
  •  北海茫月
    2021-01-29 01:59

    I forked your Plunker to add Transclusion. The Directive Transcludes the element, replacing it entirely. It then takes the cloned (original contents) and inserts them into the Transclusion, making the original elements become compiled as part of the directive.

    app.directive('cronosDataset',[function() {
      return {
        restrict: 'A',
        controller:'TestController',
        controllerAs: "ctrl",
        scope: {
            cronosDataset : "@"
        },
        transclude: 'element',
        replace: true,
        link: function(scope, elem, attrs, ctrl, transclude) {
          transclude(scope, function(clone) {
            elem.after(clone);
          });
        }
      };
    }])
    

    0 讨论(0)
提交回复
热议问题