Home  >  Article  >  Web Front-end  >  How to add tr to table in angularjs

How to add tr to table in angularjs

php中世界最好的语言
php中世界最好的语言Original
2018-04-12 16:02:551269browse

This time I will show you how to add tr to the table in angularjs. What are the precautions for adding tr to the table in angularjs? The following is a practical case, let's take a look.

The above is a table using


Loop display. One of the current requirements is that a field needs to be added to each row, but it cannot be displayed on the same row and needs to be displayed on the next row. I first thought of adding it directly, but there was no way to change the line. It won't do to add another one below. You can only rely on powerful angulajs and custom instructions. Let’s get started. 

1 Custom instructions

.directive(
   'kbnTableRow',
   function($compile) {
    return {
    restrict : 'A',
    link : function(scope, element) {
    element.after('');
   function expressDescHtml() {
   var detailHtml = ''
   + '

'     + '

'  + ' ' + '

' +'

' + ''; return detailHtml;     }   },  templateUrl : 'libs/kbnTable/table_row/rule.html'       };      });

2 rule.html is the original content


 

{{$index+1}}

 

   {{rule.rightVar.desc}}

 

  

      

  

      

 

 

    

    
There is no need to change, whatever it is originally is written here.

3 Rewrite the tr loop part in the initial page with our new command:

   

    

     表达式设置     

   

   

    

     

      

                                                                                                                       
                               序号左变量操作符右变量分值操作
     

     

            

    

   

In this way, our initial requirements can be completed, but with slight changes above, better functions will be achieved. The following line can be automatically shrunk:

I believe you have mastered the method after reading the case in this article, and there will be more exciting things. Please pay attention to other related articles on php Chinese website!

Recommended reading:

Detailed explanation of vue global registration and local registration usage

How to deal with the compatibility of easyui date and time box in IE

The above is the detailed content of How to add tr to table in angularjs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn