简体   繁体   中英

Minify css - remove angularjs expression in inline style for markup file

I working with angularjs.

In markup file, I have an inline style like this:

<div class="progress-bar"
    style="display: block; width: {{::provision.precision}}%">
</div>

I minify this html code by grunt-contrib-htmlmin . Here is grunt config:

htmlmin: {
  dist: {
    options: {
      collapseWhitespace: false,
      conservativeCollapse: false,
      collapseBooleanAttributes: true,
      removeComments: true,
      removeCommentsFromCDATA: true,
      removeOptionalTags: true,
      minifyJS: {
        mangle: false
      },
      minifyCSS: true
    },
    files: [{
      expand: true,
      cwd: '<%= yeoman.dist %>',
      src: [
        '*.html',
        'views/{,*/}*.html'
      ],
      dest: '<%= yeoman.dist %>'
    }]
  }
}

There is minifyCSS inside htmlmin to minify inline style using grunt-contrib-cssmin .

The result after minify like that:

<div class="progress-bar" style="display: block;"></div>

There is no width in style attribute.

Does anyone know how to config minifyCSS to keep width: {{::provision.precision}}% after minify?

I found solution.

Use ng-style instead of style attribute. That's all!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM