Nelson
Nelson

Reputation: 383

angularJs -- inside the (Link) directive html not working

Hi inside the (Link) directive html not working

I am created (href, icon) directives (common directives), here values are coming based on the conditions (if), but Testing not bind the setValues(templates).

var app = angular.module('testApp', []);
app.directive('comonLink', ['$http', function($http) {

  return {
    restrict: 'AEC',
    require: '',
    scope: {
      setValues:'@',     
    },
    template:'<div  > {{ setValues }} </div>',

    link: function(scope, iElement, iAttrs, ngModelController) {
      var comonLink=iAttrs.comonLink;
      var splitValues=comonLink.split(",");

      if(splitValues[0]=='link'){
        scope.setValues="<a href=''> Testing </a>";
      }

    }
  };
}]);  


<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body data-ng-app="testApp"  > 
  <div class="wrapper">        
    <span comon-Link="link,add,icon"></span>              
</body>

Upvotes: 2

Views: 41

Answers (1)

Guenter Guckelsberger
Guenter Guckelsberger

Reputation: 940

In your html is a fault, you can't use uppercase, it should be

<span comon-link="link,add,icon">  </span>

Upvotes: 1

Related Questions