kudago / smart-app-banner

Lightweight smart app banner with no jquery requirement
MIT License
528 stars 251 forks source link

Using with Angular2 / Typescript #81

Open kodeine opened 7 years ago

kodeine commented 7 years ago

How can we use it with typescript/ angular2?

rodneyjoyce commented 7 years ago

Did you find a solution to this?

Ericky14 commented 7 years ago

Any solutions for this?

FredeHo commented 7 years ago

Everything is working as expected using Angular2 / Typescript (Ionic). What's not working for you?

Galleria commented 6 years ago

you can import libs on .angular-cli.json "styles": [ "../node_modules/smart-app-banner/dist/smart-app-banner.css" ], "scripts": [ "../node_modules/smart-app-banner/dist/smart-app-banner.js" ],

and then declare var SmartBanner: any; on component that you would like to use it. (I added it on app.componen.ts) and added new SmartBanner() on ngAfterViewInit().

finish :")

felipelopes6 commented 6 years ago

no solution yet?

Ericky14 commented 6 years ago

So, I got it to work for me.

You need to import the styles in .angular-cli.json on the styles property.

...
  "styles": ["../node_modules/smart-app-banner/dist/smart-app-banner.css"]
...

Then on app.components.ts I do

import SmartBanner from 'smart-app-banner';
...
  constructor() {
    new SmartBanner({
      daysHidden: 10,   // days to hide banner after close button is clicked (defaults to 15)
      daysReminder: 20, // days to hide banner after "VIEW" button is clicked (defaults to 90)
      // appStoreLanguage: 'us', // language code for the App Store (defaults to user's browser language)
      title: 'Title',
      author: 'Authot',
      button: 'VIEW',
      store: {
        ios: 'On the App Store',
        android: 'In Google Play'
      },
      price: {
        ios: 'FREE',
        android: 'FREE'
      },
      // force: 'android' // Uncomment for platform emulation
    });
  }
...
felipelopes6 commented 6 years ago

I tried this : https://github.com/kudago/smart-app-banner/issues/99