Front-end - How to get the name attribute of a custom tag in angular?
阿神
阿神 2017-05-15 16:49:12
0
1
678
<livebit name="" age=""></livebit>

Get the name attribute in the link of the command

阿神
阿神

闭关修行中......

reply all(1)
大家讲道理

You need to write your own directive for this, example:

<livebit name="" age=""></livebit>

 angular.module('MyApp').directive('livebit', [function() {
    return {
        restrict: 'E',  
        link: function (scope, elm, attrs) {
             arrts.name  //就可以拿到 name的值
             attrs.age //同上哦
        };
}]);

// restrict 的取值
     E == element(根据元素名找 livebit)
     C == class (根据类名来找 livebit)
     A == attribute (根据属性名找 livbit)
     ACE == 能找的都找

So your custom tag can be written in the following ways:
There is this:

restrict = 'E'
<livebit name="" age=""></livebit>

This kind:

    restrict = 'C'
<p class="livebit" name="" age=""></p>

There is also this:

restrict = 'C'
<p name="" age="" livebit></p>

After finding the element, you can do whatever you want with your label through the link callback.
For example

请输入代码
  elm.appendChild(xxxxx)
  $(elm).jquery-插件xxx()
  .........
 ...........
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template