1

I know there is no direct integration of FlowJs with angular2 so i am trying to implement it by following ways but didn't get any success:

By Declare direct:

Included flow.js script file in index.html and following is the code of component.ts file:

import { Component, OnInit } from '@angular/core';
declare var Flow: any;

@Component({
    selector: 'dashboard-page',
    templateUrl: 'dashboard.component.html'
})

export class DashboardComponent implements OnInit {
    public message: string;

    constructor() {
        this.message = 'Dashboard';
    }
    ngOnInit() {
        var flow = new Flow({
            target: '/api/photo/redeem-upload-token',
            query: { upload_token: 'my_token' }
        });
    }
}

In this its giving me error: ' Flow is not defined'

By using @typings:

I have installed the @typings by @types/flowjs and then installed flow.js by using "npm install --save-dev @flowjs/flow.js" and then i have written following code in my component:

import { Component, OnInit } from '@angular/core';
import * as Flow from "@types/flowjs"; 
//or

//import * as Flow from "flowjs"; @Component({ selector: 'dashboard-page', templateUrl: 'dashboard.component.html' })

export class DashboardComponent implements OnInit {
    public message: string;

    constructor() {
        this.message = 'Dashboard';
    }
    ngOnInit() {
        var flow = new Flow({
            target: '/api/photo/redeem-upload-token',
            query: { upload_token: 'my_token' }
        });
    }

}

But in this its giving an error: "/node_modules/@types/flowjs/index.d.ts' is not a module".

How can i implement FlowJs with angular2?

Manjit
  • 221
  • 2
  • 4
  • 15
  • Perhaps try `import * as flow from '@flow/dist/flow'` ? – Joe Keene Apr 27 '17 at 14:34
  • @JoeKeene- my folder structure is "node_modules\@flowjs\flow.js\dist" and in dist folder there is flow.js (javascript) file exist not ts file and i tried "import * as flow from '@flowjs/flow.js/dist/flow'" but its showing cannot find module. And In my "@types" i have this structure "\node_modules\@types\flowjs" and in the flowjs folder i have index.d.ts,packages.json,types-metadata.json files exist. And i have also added the index.d.ts data in quesition. – Manjit Apr 28 '17 at 06:36
  • Ah ok - have you looked at this answer http://stackoverflow.com/questions/40379116/using-flow-js-in-angular-2-typescript ? – Joe Keene Apr 28 '17 at 06:42

0 Answers0