Comments (8)
Yeah!, This is supported now. Here's are the overall steps to get this working with Angular 2:
-
Add these to your
dependencies
section in yourpackage.json
:"nativescript-floatingactionbutton": "2.2.1",
-
Run
npm install
. -
Add the following lines before you bootstrap (nativeScriptBootstrap) your app:
import {registerElement} from "nativescript-angular/element-registry";
registerElement("FAB", () => require("nativescript-floatingactionbutton").Fab); -
Now, you can use the
FAB
in your templateURL (HTML files) as you wish like shown below:<FAB tap="fabTap" row="1" icon="res://icon" rippleColor="#f1f1f1" class="fab-button"> </FAB>
-
Add the following to your app.css for styling:
.fab-button {
height: 70;
margin: 15;
background-color: #ff4081;
horizontal-align: right;
vertical-align: bottom;
} -
If you run into an error like this while running
tns run android
:Exception in thread "main" java.lang.IllegalArgumentException: Class com.tns.internal.AppBuilderCall
back conflict: \platforms\android\build\intermediates\classes\debug and
\platforms\android\build\intermediates\classes\nativescriptcardview
debug
at com.telerik.metadata.ClassRepo.cacheJarFile(ClassRepo.java:21)
at com.telerik.metadata.Builder.build(Builder.java:41)
at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':buildMetadata'.
Process 'command 'C:\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1 -
then, do the following:
Run
gradlew clean
in theplatforms > android
folder. -
Run
tns run android
again, it'll fix the issue and you'll see the FAB on your Angular 2 app!
from nativescript-floatingactionbutton.
uninstalling and installing again solved my problem. Thanks for the reply
from nativescript-floatingactionbutton.
I've not tried ng2 with NativeScript yet, holding out for end of beta 😄 However, I'm pretty sure you can use this with ng2, I think some people have been doing so from the conversations on the community slack channel. You might want to drop in there and ask around to see.
from nativescript-floatingactionbutton.
@Headcult you figured it out correct? If so, go ahead and close this and list the solution for future users. Thanks.
from nativescript-floatingactionbutton.
If anyone's having a hard time getting the tap to register in the angular 2 component, just change
tap="fabTap"
to (tap)="fabTap()"
from nativescript-floatingactionbutton.
Hey, Im getting some sort of android error. I have tried gradle clean and replacing android platform too.
Any Help! Thanks!
Error: Error in pages/list/list.html:47:2 caused by: Could not load view for: FAB.Error: com.tns.NativeScriptException: Failed to find module: "nativescript-floatingactionbutton", relative to: app/tns_modules/ JS: com.tns.Module.resolvePathHelper(Module.java:159) JS: com.tns.Module.resolvePath(Module.java:60) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1022) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:907) JS: com.tns.Runtime.callJSMethod(Runtime.java:895) JS: com.tns.Runtime.callJSMethod(Runtime.java:879) JS: com.tns.Runtime.callJSMethod(Runtime.java:871) JS: com.tns.gen.android.view.View_OnTouchListener.onTouch(android.view.View$OnTouchListener.java) JS: android.view.View.dispatchTouchEvent(View.java:9290) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) JS: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) JS: com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403) JS: com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737) JS: android.app.Activity.dispatchTouchEvent(Activity.java:2765) JS: com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364) JS: android.view.View.dispatchPointerEvent(View.java:9514) JS: android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230) JS: android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096) JS: android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) JS: android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) JS: android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) JS: android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787) JS: android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) JS: android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844) JS: android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) JS: android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) JS: android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) JS: android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) JS: android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) JS: android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922) JS: android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896) JS: android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857) JS: android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025) JS: android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) JS: android.os.MessageQueue.nativePollOnce(Native Method) JS: JS: android.os.MessageQueue.next(MessageQueue.java:323) JS: android.os.Looper.loop(Looper.java:135) JS: android.app.ActivityThread.main(ActivityThread.java:5417) JS: java.lang.reflect.Method.invoke(Native Method) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
from nativescript-floatingactionbutton.
from nativescript-floatingactionbutton.
Do I add the Element registration code to main.ts,
before the following line?
platformNativeScriptDynamic().bootstrapModule(AppModule);
This is the code I'm talking about:
import {registerElement} from "nativescript-angular/element-registry";
registerElement("FAB", () => require("nativescript-floatingactionbutton").Fab);`
I'm getting an error when loading the page stating
Cannot read property "FloatingActionButton" of undefined, undefined.
HTML:
https://paste.ofcode.org/UMwk44gTkCtwbR9KfC2dh8
TS:
https://paste.ofcode.org/uFTEYn6wV65LgPG9ZtbKju
from nativescript-floatingactionbutton.
Related Issues (20)
- Can I remove padding around icon? HOT 1
- Calling js method onCreateView failed HOT 2
- Error when adding the plugin HOT 1
- JS: topmost() is deprecated. Use Frame.topmost() instead. HOT 2
- How to use svg images HOT 2
- Fab is not showing when scroll completes HOT 1
- text is not working. HOT 6
- loadFromFontIconCode() is deprecated HOT 4
- Adapt icon to screen HOT 10
- Styles not applied on app build for production HOT 2
- FAB 2.0.1: font icons have different sizes on different screens HOT 1
- Crash in flexbox-layout.android.js - Right-hand side of 'instanceof' is not an object HOT 5
- NativeScript 7 update HOT 1
- Could not load view for: Fab.ReferenceError: NativeClass is not defined when used with {N} 7 with angular HOT 12
- FAB.TypeError: core_1.Property is not a constructor HOT 5
- Changing color to text does not work HOT 6
- Display the action items when Fab Button is clicked - Nativescript7 Angular10 HOT 3
- @nativescript/core still imported for lower version than NS7
- icon appearing bigger and cannot be resized HOT 2
- App is crashing on NS Angular
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-floatingactionbutton.