how to set 'Page' level properties in angular component
See original GitHub issueHi! i’m using angular2-seed-advanced, web + mobile with angular+nativescript, i’m trying to set my background sitting under statusbar using opaqueTokens, but somehow it don’t work. My code: Token.ts
import {OpaqueToken} from '@angular/core';
export const PAGE: OpaqueToken = new OpaqueToken('page');
App.ts
nativeScriptBootstrap(NSAppComponent, [
provide(WindowService, {useClass: WindowNative}),
provide(PAGE, {useClass: Page}),
ModalNative,
provide(HttpService, {useClass: NSHttpService}),
provide(TranslateLoader, {
useFactory: () => {
return new TNSTranslateLoader('assets/i18n');
}
}),
NS_APP_PROVIDERS,
nsProvideRouter(routes, {enableTracing: false})
]);
myComponent.ts
constructor(@Inject (PAGE) private page:PAGE) {
if (CoreConfigService.IS_MOBILE_NATIVE) {
console.log(this.page.ios);
this.page.actionBarHidden = true;
this.page.backgroundSpanUnderStatusBar=true;
this.page.backgroundImage = this.page.ios ? "res://bg_login.jpg" : "res://bg_login";
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
Component styles - Angular
One way to do this is to set the styles property in the component metadata. The styles property takes an array of strings...
Read more >Angular components overview
Navigate to your Angular project directory. · Create a new file, <component-name>. · At the top of the file, add the following import...
Read more >Common Routing Tasks - Angular
For the component property, you can define any component in your application. Common choices include an application-specific PageNotFoundComponent , which you ...
Read more >Property binding - Angular
To bind the src property of an <img> element to a component's property, place src in square brackets followed by an equal sign...
Read more >Content projection - Angular
Create a component. In the template for your component, add an <ng-content> element where you want the projected content to appear. For ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just to conclude, turns out his issue was related to fact that when using an
OpaqueToken
to build a web/{N} shared codebase, one must provide thePAGE
OpaqueToken
in the correct way, for instance this works:Works wonderfully and ensures that it doesn’t break the web 👍
@NathanWalker This method looks good but I haven’t been able to get this to work. Is provide a class I should import or create? Or has the standard changed?