GithubHelp home page GithubHelp logo

Comments (10)

moayadnajd avatar moayadnajd commented on September 24, 2024 5

hi all i fixed the first issue by edit the app.ts code as below

var resources = application.getResources();
resources['fonticon'] = fonticon;
resources['isActive'] = isActive;
application.setResources(resources);
as @AdamDenoon mentioned

from nativescript-fonticon.

AdamDenoon avatar AdamDenoon commented on September 24, 2024 3

@uzarsalan That variable is unrelated to the issue and fonticon in general.

from nativescript-fonticon.

madsongr avatar madsongr commented on September 24, 2024 1

Solved. It was missing import application = require('application');

from nativescript-fonticon.

AdamDenoon avatar AdamDenoon commented on September 24, 2024

Same here:

tns --version
3.0.3

iOS Error:
JS ERROR TypeError: undefined is not an object (evaluating 'application.resources['fonticon'] = fonticon')

Android Error:

TypeError: Cannot set property 'fonticon' of undefined
File: "file:///<app.js>, line: 14, column: 34

Offending line: application.resources['fonticon'] = fonticon;

Offending part of line: application.resources['fonticon']<

Application.resources no longer has 'fonticon' as a property.

EDIT: I just upgraded to NativeScript 3.0.3, and that's when it stopped working.

from nativescript-fonticon.

AdamDenoon avatar AdamDenoon commented on September 24, 2024

Output of console.dir(application) yields:

=== dump(): dumping function and properties names ===
JS: Observable()
JS: hasLaunched()
JS: getResources()
JS: setResources()
JS: on()
JS: off()
JS: notify()
JS: hasListeners()
JS: setApplication()
JS: livesync()
JS: setCssFileName()
JS: getCssFileName()
JS: addCss()
JS: AndroidApplication()
JS: start()
JS: getMainEntry()
JS: getNativeApplication()
JS: getOrientation()
JS: === dump(): finished ===

This tells me that the new way to set the resources for the application is to use the setResources() method.

To fix this issue, replace application.resources['fonticon'] = fonticon; with application.setResources(fonticon);

from nativescript-fonticon.

wiliarko avatar wiliarko commented on September 24, 2024

How do i access that fonticon?

<Label text="{{ sp_icon | fonticon }}" class="ion" style="font-size:30;" />
JS: Cannot find function or filter: fonticon

from nativescript-fonticon.

AdamDenoon avatar AdamDenoon commented on September 24, 2024

I had the same problem. I just ensured I had "fa" listed as a class on my XML element, then loaded the icon via JS:

<Button id="next-button" class="fa" text="" onTap="callAction" />

var fonticon = application.getResources(fonticon);
. . .
var nextButton = page.getViewById("next-button");
nextButton.text = fonticon('fa-chevron-right');

from nativescript-fonticon.

Aris-ngoy avatar Aris-ngoy commented on September 24, 2024

i am having the same problem even after creating a new project it isnt working on ns 3.0.3 tsc or js but on angular is working fine

from nativescript-fonticon.

uzarsalan avatar uzarsalan commented on September 24, 2024

What variable isActive?

from nativescript-fonticon.

madsongr avatar madsongr commented on September 24, 2024

I have the same issue and I get no errors after using @moayadnajd ยดs answer but my icons are not displayed:

app.ts:

import  * as application from 'application';
import {TNSFontIcon, fonticon} from 'nativescript-fonticon';

//TNSFontIcon.debug = true;
TNSFontIcon.paths = {
  'fa': 'font-awesome.css',
  'ion': 'ionicons.css'
};
TNSFontIcon.loadCss();

var resources = application.getResources();
resources['fonticon'] = fonticon;
application.setResources(resources);

application.start({ moduleName: 'main-page' });

app.css:

.fa {
    font-family: FontAwesome, fontawesome-webfont;
    font-size:60;
  }

.ion {
   font-family: Ionicons, ionicons;
   font-size:60;
}

main-page.xml:

<GridLayout rows="auto auto" columns="50 *">
    <Label class="fa" text="{{'fa-user' | fonticon}}" row="0" col="0" horizontalAlignment="center" verticalAlignment="center"/>
    <TextField hint="Email" keyboardType="email" autocorrect="false" autocapitalizationType="none" row="0" col="1"/>
            
    <Label class="fa" text="{{'fa-lock' | fonticon}}" row="1" col="0" horizontalAlignment="center" verticalAlignment="center"/>
    <TextField hint="Pass" secure="true" row="1" col="1"/>
</GridLayout>

from nativescript-fonticon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.