замените templateUrl на шаблон в Angular-компоненте, используя загрузчик webpack - PullRequest
0 голосов
/ 24 декабря 2018

Какой загрузчик может заменить угловой компонент templateurl на template?Работает правильно при использовании угловых CLI и Angular.json.Тем не менее, я использую Webpack, и это работает неправильно.

test-component.ts

import {Component, OnInit} from '@angular/core';

@Component({
    selector: 'lib-test',
    templateUrl: 'test-component.html'
})
export class TestComponent implements OnInit {

    ngOnInit(): void {
        throw new Error('Method not implemented.');
    }

}

test-component.html

<div>azizkhani</div>

для проверки-component.js

/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes} checked by tsc
 */
import { Component } from '@angular/core';
export class JhiTestComponent {
    /**
     * @return {?}
     */
    ngOnInit() {
        throw new Error('Method not implemented.');
    }
}
JhiTestComponent.decorators = [
    { type: Component, args: [{
                selector: 'lib-test',
                template: `<div>azizkhani</div>`
            },] },
];

код выше, сгенерированный с помощью angular.json, мой webpack.config.js похож на это

module: {
        rules: [{
            enforce: 'pre',
            test: /\.ts$/,
            loader: 'tslint-loader',
            exclude: [helpers.root('node_modules')]
        }, {
            test: /\.html$/,
            loader: 'html-loader',
            options: {
                minimize: true,
                caseSensitive: true,
                removeAttributeQuotes: false,
                minifyJS: false,
                minifyCSS: false
            },
            exclude: /(src\/main\/webapp\/index.html)/
        }, {
            test: /\.ts$/,
            use: [
                'angular2-template-loader',
                {
                    loader: 'ts-loader',
                    options: {
                        transpileOnly: true,
                        happyPackMode: true
                    }
                },
                'angular-router-loader'
            ],
            exclude: /(node_modules)/
        }]
    },
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...