2016-09-11 12 views

答えて

4

ng2-responsiveパッケージには、あなたのカバーすべきである: 、@Viewデコレータは、このような*ngIfを使用している交換する最高の瞬間での角度2.

2

でこの機能を実装する方法を、私のベストプラクティスを教えてくださいニーズ:https://www.npmjs.com/package/ng2-responsive

私はそれを広範に使用していませんが、まともな仕事をしているようです。

@View@Component(複数年前)にマージされました。 @Componentが必要な唯一のデコレータである必要があります。

4
@Component({ 
    selector: 'my-component', 
    templateUrl: "./" + (window.screen.width > 900 ? 
        "my-component.desktop.html" : 
        "my-component.mobile.html"), 
    styleUrls: ['./my-component.css'] 
}) 
+0

Angular2は、サーバー側のレンダリングを使用するため、@Componentデコレータは、ウィンドウへのアクセスhttps://juristr.com/blog/2016/09/ng2-get-windowを持っていないので、これは動作しません。 -ref / – hugostacks

関連する問題