ASP.NET核心断层板永远无法使角材料工作



我已经尝试数周将角材料从Microsoft中获取到空间板中。有人可以帮助我理解为什么我只是不能遵循《角材料的启动指南》并有效吗?有人可以帮助我获取一个项目,以至于我可以开始使用Spatemplate的Angular材料。

我已经关闭了服务器端的预渲染,因为我知道这会导致问题。但是除此之外,我尝试安装角度材料,我还会在CMD中看到一些错误。我导入并添加材料模块,然后看到更多关于'ng-template' is not a known element的错误。我从进口阵列中删除了通用模块,这会导致更多问题。

在这里回购如果有人可以帮忙。repo

我也是唯一来自Angular 1.x并且说实话根本不感兴趣的开发人员吗?Angular 1很容易开发,设置并不难,并且添加外部代码就像复制和粘贴一样容易。Angular 2感觉就像他们制作了这个非常出色的框架,然后没人知道如何在服务器上托管它。

我从刚刚以核心2释放的新模板开始

尝试启动和其他,没有成功。最接近材料。

希望这对...仍然是新手。

进行更改后,不要忘记手动重建WebPack。webpack -config webpack.config.vendor.js

webpack.dendor

const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const merge = require('webpack-merge');
const treeShakableModules = [
    '@angular/animations',
    '@angular/common',
    '@angular/compiler',
    '@angular/core',
    '@angular/forms',
    '@angular/http',
    '@angular/platform-browser',
    '@angular/platform-browser-dynamic',
    '@angular/router',
    '@angular/material',
    '@angular/cdk',
    'zone.js'

];
const nonTreeShakableModules = [
    'bootstrap',
    'hammerjs/hammer',
    "@angular/material/prebuilt-themes/indigo-pink.css",
    'bootstrap/dist/css/bootstrap.css',
    'font-awesome/css/font-awesome.css',
    'es6-promise',
    'es6-shim',
    'event-source-polyfill',
    'jquery',
];
const allModules = treeShakableModules.concat(nonTreeShakableModules);
module.exports = (env) => {
    const extractCSS = new ExtractTextPlugin('vendor.css');
    const isDevBuild = !(env && env.prod);
    const sharedConfig = {
        stats: { modules: false },
        resolve: { extensions: [ '.js' ] },
        module: {
            rules: [
                { test: /.(png|woff|woff2|eot|ttf|svg|gif|jpg)(?|$)/, use: 'url-loader?limit=100000' }
            ]
        },
        output: {
            publicPath: 'dist/',
            filename: '[name].js',
            library: '[name]_[hash]'
        },
        plugins: [
            new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
            new webpack.ContextReplacementPlugin(/@angularb.*b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580
            new webpack.ContextReplacementPlugin(/angular(\|/)core(\|/)@angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898
            new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
        ]
    };
    const clientBundleConfig = merge(sharedConfig, {
        entry: {
            // To keep development builds fast, include all vendor dependencies in the vendor bundle.
            // But for production builds, leave the tree-shakable ones out so the AOT compiler can produce a smaller bundle.
            vendor: isDevBuild ? allModules : nonTreeShakableModules
        },
        output: { path: path.join(__dirname, 'wwwroot', 'dist') },
        module: {
            rules: [
                { test: /.css(?|$)/, use: extractCSS.extract({ use: isDevBuild ? 'css-loader' : 'css-loader?minimize' }) }
            ]
        },
        plugins: [
            extractCSS,
            new webpack.DllPlugin({
                path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
                name: '[name]_[hash]'
            })
        ].concat(isDevBuild ? [] : [
            new webpack.optimize.UglifyJsPlugin()
        ])
    });
    const serverBundleConfig = merge(sharedConfig, {
        target: 'node',
        resolve: { mainFields: ['main'] },
        entry: { vendor: allModules.concat(['aspnet-prerendering']) },
        output: {
            path: path.join(__dirname, 'ClientApp', 'dist'),
            libraryTarget: 'commonjs2',
        },
        module: {
            rules: [ { test: /.css(?|$)/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] } ]
        },
        plugins: [
            new webpack.DllPlugin({
                path: path.join(__dirname, 'ClientApp', 'dist', '[name]-manifest.json'),
                name: '[name]_[hash]'
            })
        ]
    });
    return [clientBundleConfig, serverBundleConfig];
}

i使用app.module.shared与从索引中删除的ASP渲染。

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule} from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app/app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
import { HttpTestComponent } from './components/Httptest/httptest.component';
import { MaterialTesterComponent } from './components/Httptest/materialTester.component';
import { MaterialGridComponent } from './components/Httptest/materialgrid.component';

import { MaintService } from './Services/maint.service';

import {
    MdButtonModule,
    MdChipsModule,
    MdProgressSpinnerModule,
    MdCardModule,
    MdDatepickerModule,
    MdInputModule,
    MdAutocompleteModule,
    MdNativeDateModule,
    MdCheckboxModule,
    MdRadioModule,
    MdSelectModule,
    MdSliderModule,
    MdSlideToggleModule,
    MdMenuModule,
    MdListModule,
    MdGridListModule,
    MdTabsModule,
    MdProgressBarModule,
    MdTableModule,
    MdCoreModule,
    MdExpansionModule,

} from '@angular/material';
import { CdkTableModule } from '@angular/cdk';

@NgModule({
    declarations: [
        AppComponent,
        NavMenuComponent,
        CounterComponent,
        FetchDataComponent,
        HomeComponent,
        HttpTestComponent,
        MaterialTesterComponent,
        MaterialGridComponent,
    ],
    imports: [
        CommonModule,
        HttpClientModule,
        FormsModule,
        ReactiveFormsModule,
        CdkTableModule,
        MdButtonModule,
        MdChipsModule,
        MdProgressSpinnerModule,
        MdCardModule,
        MdInputModule,
        MdTabsModule,
        MdExpansionModule,
        MdDatepickerModule,
        MdNativeDateModule,
        MdCheckboxModule,
        MdRadioModule,
        MdListModule,
        MdCoreModule,
        MdProgressBarModule,
        MdSelectModule,
        MdSliderModule,
        MdSlideToggleModule,
        MdMenuModule,
        MdGridListModule,
        MdTableModule,
        MdAutocompleteModule,
          RouterModule.forRoot([
            { path: '', redirectTo: 'home', pathMatch: 'full' },
            { path: 'home', component: HomeComponent },
            { path: '**', redirectTo: 'home' }
        ])
    ],
    providers: [
        MaintService
    ]
})
export class AppModuleShared {
}

最新更新