Я новичок в angular и пытаюсь показать / скрыть текст в соответствии с размером экрана.Я хочу скрыть часть содержимого в представлении вкладок и часть содержимого в представлении для мобильных устройств.Я искал решение и нашел одну ссылку для ng2-if-media .Я установил этот модуль, но похоже, что он будет работать для Angular 2, а не для Angular 5.
Я добавил константу mediaConfig в файл app.module.ts после запуска npm install --save ng2-if-media
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { RECAPTCHA_SETTINGS, RecaptchaModule, RecaptchaSettings } from 'ng-recaptcha';
import { RecaptchaFormsModule } from 'ng-recaptcha/forms';
import { AgmCoreModule } from '@agm/core';
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner';
import { DeviceDetectorModule } from 'ngx-device-detector';
import { environment } from '../environments/environment';
import { ApiModule, ProfileService, PropertyService } from './api';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AuthModule } from './auth';
import { DummyComponent } from './dummy.component';
import { InterceptorsModule } from './interceptors';
import { LoginComponent } from './login/login.component';
import { NavbarComponent } from './navbar/navbar.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { ProfileComponent } from './profile/profile.component';
import { SharedModule } from './shared';
import { UserModule } from './user';
import { SignupFormComponent } from './user/signup-form/signup-form.component';
import { SearchComponent } from './search/search.component';
import { SearchResultlistComponent } from './search/search-resultlist/search-resultlist.component';
import { SearchResultComponent } from './search/search-result/search-result.component';
import { ProfileSearchFormComponent } from './profile/profile-search-form/profile-search-form.component';
import { ProfileViewComponent } from './profile/profile-view/profile-view.component';
import { ProfileEditComponent } from './profile/profile-edit/profile-edit.component';
import { ErrorComponent } from './error/error.component';
import { InquiriesComponent } from './inquiries/inquiries.component';
import { InquiryItemComponent } from './inquiries/inquiry-item/inquiry-item.component';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { NgxIntlTelInputModule } from 'ngx-intl-tel-input';
import { TenantDetailComponent } from './profile/tenant-detail/tenant-detail.component';
import { IfMediaModule } from 'ng2-if-media';
const mediaConfig = {
breakpoints: {
tablet: {
value: '768px',
param: 'width'
},
budgetHeight: {
value: '480px',
param: 'height'
},
widescreen: {
value: '1280px',
param: 'width'
},
print: {
media: 'print'
},
landscape: '(orientation: landscape)'
},
vendorBreakpoints: ['bootstrap'], // include 3rd party namespace
throttle: 100
};
@NgModule({
declarations: [
AppComponent,
LoginComponent,
NavbarComponent,
SignupFormComponent,
DummyComponent,
PropertyComponent,
PropertySearchFormComponent,
PropertyViewComponent,
SearchComponent,
SearchResultlistComponent,
SearchResultComponent,
ProfileSearchFormComponent,
NotFoundComponent,
ProfileComponent,
ProfileViewComponent,
ProfileEditComponent,
ErrorComponent,
InquiriesComponent,
InquiryItemComponent,
PropertyEditComponent,
InquiryItemFormComponent,
AccountComponent,
AccountViewComponent,
AccountEditComponent,
PasswordResetComponent,
PasswordResetSendComponent,
PasswordResetSubmitComponent,
UserAuthentificationComponent,
GlobalNotificationsDirective,
SearchInfoWindowComponent,
DashboardComponent,
TenantDetailComponent,
],
imports: [
NgbModule.forRoot(),
AgmCoreModule.forRoot({
apiKey: environment.googleMapApiKey,
libraries: ["places"]
}),
BrowserModule,
FormsModule,
ReactiveFormsModule,
RecaptchaModule.forRoot(),
RecaptchaFormsModule,
AppRoutingModule,
ApiModule.forRoot(),
AuthModule.forRoot(),
InterceptorsModule,
SharedModule,
UserModule,
[FroalaEditorModule.forRoot(), FroalaViewModule.forRoot()],
[Ng4LoadingSpinnerModule.forRoot()],
DeviceDetectorModule.forRoot(),
BsDropdownModule.forRoot(),
NgxIntlTelInputModule,
IfMediaModule.withConfig(mediaConfig)
],
providers: [
{
provide: RECAPTCHA_SETTINGS,
useValue: { siteKey: environment.recaptchaSiteKey } as RecaptchaSettings
}
],
bootstrap: [AppComponent]
})
export class AppModule { }
В своем файле .html я использую его как
<h4 il8n="@@username" class="text-uppercase mb-2" *ifMedia="<tablet">EMMA HAUSER - MANSON</h4>
Может кто-нибудь сообщить мне, где я не прав, или это будет работать для угловых 5 или нет?