Angular2应用程序中

Angular2应用程序中

本文介绍了如何使用Electron的< webview>在Angular2应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用在我的Angular2应用程序中,但是当我添加绑定到Angular2变量的src属性时,会发生以下错误:

I try to use Electon's webview tag inside my Angular2 app, but when I add the src attribute binded to an Angular2 variable, the following error occurs:

Can't bind to 'src' since it isn't a known native property

这是索引.html:

<head>
    <!-- cut out stylings, metatags, etc. -->
    <script src="../node_modules/zone.js/dist/zone.js"></script>
    <script src="../node_modules/reflect-metadata/Reflect.js"></script>
    <script src="../node_modules/systemjs/dist/system.src.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
        const electron = require('electron');
        System.import('app').catch(function(err){ console.error(err); });
    </script>
</head>
<body>
    <MainComponent>Loading...</MainComponent>
</body>

这是systemjs.config.js:

This is the systemjs.config.js:

(function(global) {
// map tells the System loader where to look for things
var map = {
    'app':                        'angular',
    '@angular':                   '../node_modules/@angular',
    'angular2-in-memory-web-api': '../node_modules/angular2-in-memory-web-api',
    'rxjs':                       '../node_modules/rxjs'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { defaultExtension: 'js' }
};
var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade'
];
// Add package entries for angular packages
ngPackageNames.forEach(function(pkgName) {
    packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
});
var config = {
    map: map,
    packages: packages
};
System.config(config);
})(this);

这是我(想)在以下位置使用webview的Angular2组件模板:

This is the Angular2 component template I (want to) use webview in:

<div class="stage-component component">
    <webview *ngIf="iFrameUrl" src="{{iFrameUrl}}"></webview>
</div>

如何将webview元素引入Angular2?

How can I introduce the webview element to Angular2?



解决方案
If this appears, use "attr" before.

如果出现,请在前面加上 attr。 webview * ngIf = iFrameUrl attr.src = {{iFrameUrl}}>< / webview>

<webview *ngIf="iFrameUrl" attr.src="{{iFrameUrl}}"></webview>

这篇关于如何使用Electron的&lt; webview&gt;在Angular2应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 05:02