WinJS and Angular2 Integration

I am trying to wrap a WinJS rating rating in an Angular2 component . When I debug, I see that WinJS.UI.processAll (); called and executed. But I do not see rating control.

How can I make it work?

Dashboard.cshtml

@{
    ViewBag.Title = "Dashboard";
}

<my-app></my-app>

<script src="/jspm_packages/system.js"></script>
<script src="/config.js"></script>

<script>
    System.import('reflect-metadata')
        .then(function () {
            System.import('angular2')
                .then(function () {
                    System.import("/js/app");
                });
        });
</script>

app.js

import { Component, View, bootstrap } from 'angular2';
import 'reflect-metadata';
import 'winjs';

@Component({
    selector: 'my-app'
})
@View({
    template: '<div data-win-control=\'WinJS.UI.Rating\' data-win-options=\'{averageRating: 3.4}\'></div>'
})
class MyAppComponent {
    constructor() {
    }

    onInit() {
        WinJS.UI.processAll();
    }
}

bootstrap(MyAppComponent);
+4
source share
1 answer

At the request of @wonderfulworld

First of all, according to Adding a Windows Library for JavaScript to your page , you must add the css file to your html.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.3.0/css/ui-light.min.css">

-, 37 + , onInit (. LifecycleEvent).

import { Component, View, bootstrap, OnInit} from 'angular2/angular2';
import 'reflect-metadata';
import 'winjs';

@Component({
    selector: 'my-app'
})
@View({
    template: '<div data-win-control=\'WinJS.UI.Rating\' data-win-options=\'{averageRating: 3.4}\'></div>'
})
class MyAppComponent implements OnInit {
    onInit() {
        WinJS.UI.processAll();
    }
}

. plnkr.

, ;)

+3

Source: https://habr.com/ru/post/1608978/


All Articles