这不起作用:
<div [style.-moz-column-count]="columns"></div>
<div [ngStyle]="{'-moz-column-count': columns}"></div>
<div style="-moz-column-count: {{columns}}"></div>
有没有办法避免Sanitizer?我找到了一个绕过该值的Pipe,但没有找到属性名称。
import {DomSanitizationService} from '@angular/platform-browser';
@Pipe({name: 'safe'})
export class SafePipe {
constructor(sanitizer:DomSanitizationService){
this.sanitizer = sanitizer;
}
transform(style) {
return this.sanitizer.bypassSecurityTrustStyle(style);
}
}
使用此属性的任何想法?
答案 0 :(得分:2)
你需要这样写:
this.style = {
"MozColumnCount": 3,
"column-count": 3,
}
<div [ngStyle]="style">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.
</div>
答案 1 :(得分:1)
我认为使用angular2 ngStyle
可能无法实现。
你可以使用ngClass
选项并像这样scss:
@for $i from 1 through 6 {
.columns-#{$i} {
-webkit-column-count: #{$i};
-moz-column-count: #{$i};
column-count: #{$i};
}
}