Ser*_*Sev 9 angular2-template angular
我正在开发基于版本桌面/移动版的略有不同功能的网站.
我尝试通过@View应用它,但看起来这个装饰器现在已被弃用.请告诉我最佳实践,如何在Angular 2中实现此功能.
@Component({
selector: 'my-component',
templateUrl: "./" + (window.screen.width > 900 ?
"my-component.desktop.html" :
"my-component.mobile.html"),
styleUrls: ['./my-component.css']
})
Run Code Online (Sandbox Code Playgroud)
该ng2-responsive软件包应满足您的需求:https : //www.npmjs.com/package/ng2-responsive
我还没有广泛使用它,但它似乎做得不错。
@View被合并到@Component(很久以前)。@Component应该是您需要的唯一装饰器。
| 归档时间: |
|
| 查看次数: |
6370 次 |
| 最近记录: |