Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element for FAB already registered #49

Closed
shaikhspear16 opened this issue Apr 16, 2017 · 6 comments
Closed

Element for FAB already registered #49

shaikhspear16 opened this issue Apr 16, 2017 · 6 comments

Comments

@shaikhspear16
Copy link

shaikhspear16 commented Apr 16, 2017

Nativescript + Angular:

What is the best place to register FAB?

registerElement("Fab", () => require("nativescript-floatingactionbutton").Fab);

in AppModule, AppComponent, ChildComponents gives an error "Element for FAB already registered".

@Adam95
Copy link

Adam95 commented May 5, 2017

Had the same problem. Then I placed it in my top-level app component above the class definition and it works fine now.

import {registerElement} from 'nativescript-angular/element-registry';

registerElement('Fab', () => require('nativescript-floatingactionbutton').Fab);

@Component({
  selector: "ns-app",
  templateUrl: "app.template.html"
})
export class AppComponent implements OnInit {
...
}

@bradmartin
Copy link
Collaborator

Thanks @Adam95 for the info.

@jafsparrow
Copy link

Hi.. I am getting the same error.
I tried adding those two line in AppComponent.ts.. same error.
pretty much tried with other components too.!!
any other solution..

import {registerElement} from 'nativescript-angular/element-registry';

registerElement('Fab', () => require('nativescript-floatingactionbutton').Fab);

@component({
selector: "ns-app",
templateUrl: "app.component.html",
})

@bradmartin
Copy link
Collaborator

I do this in app.component

import { Fab } from "nativescript-floatingactionbutton";
import { registerElement } from "nativescript-angular/element-registry";
registerElement("Fab", () => Fab);

and have no issues, hope that helps.

@jafsparrow
Copy link

Tried this .. same error.
If I don't add these two line, I can see floating action. but a stretched version of it.
image

I will try to add FAB in a brand new sample project and try..

@bradmartin
Copy link
Collaborator

bradmartin commented Sep 13, 2017

If it's stretched then you likely don't have a width set on it for the styler to apply. You only have to call registerElement once in your app and I do it in app.component in all of my apps and have no issue. So I'd check to make sure you don't have it called twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants