में ngSwitch का उपयोग कैसे करें पिछले दो दिनों से मैं कोणीय 2.1.0 में काम करने के लिए ngSwitch प्राप्त करने का प्रयास कर रहा हूं। लेकिन यह काम पाने के लिए असंभव लगता है।कोणीय 2
मुझे हमेशा NgSwitch के लिए कोई प्रदाता नहीं मिलता है। नीचे मेरी कोड है -
खाका -
<template [ngSwitch]="buttonSelector">
<a class="btn" [ngClass]="buttonSizeClass" *ngSwitchCase="'link'" href="#">
<span class="btn__text">
<ng-content></ng-content>
</span>
</a>
</template>
घटक -
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
import { InkedBtnComponent } from './inked-btn/inked-btn.component';
@NgModule({
imports: [
CommonModule,
RouterModule
],
declarations: [HeaderComponent, FooterComponent, InkedBtnComponent],
exports: [HeaderComponent, FooterComponent, InkedBtnComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class SharedModule { }
यह साझा मॉड्यूल फिर मुख्य मॉड्यूल में आयात किया जाता है -
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-inked-btn',
templateUrl: './inked-btn.component.html',
styleUrls: ['./inked-btn.component.css'],
inputs: ['buttonSize', 'buttonType', "buttonSelector"]
})
export class InkedBtnComponent implements OnInit {
public buttonSize: string;
public buttonType: string;
public buttonSelector: string;
public buttonSizeClass: any;
constructor() { }
ngOnInit() {
this.buttonSizeClass = {
'btn--lg': this.buttonSize === 'large',
'btn--sm': this.buttonSize === 'small',
'btn--primary': this.buttonType === 'primary'
}
}
}
नीचे मेरी मॉड्यूल विन्यास है ।
मिस कहां है?
आप BrowserModule आयातित है? – Milad
@ xe4me ब्राउज़र मॉड्यूल मुख्य मॉड्यूल में आयात किया गया है –