bleenco / ngx-uploader

Angular File Uploader
https://ngx-uploader.jankuri.me
MIT License
755 stars 348 forks source link

Can't bind to 'options' since it isn't a known property of 'input' #87

Closed itdsntwork closed 7 years ago

itdsntwork commented 8 years ago

hi. I follow the example and I get this error. I guess it's my fault but please help. I am using rc.5

jkuri commented 8 years ago

that usualy means you forgot to include UPLOAD_DIRECTIVES into NgModule declarations array.

Kbalz commented 8 years ago

I'm also struggling with this error. Using 2.0 release.

systemjs.config.js

` (function (global) { System.config({ paths: { // paths serve as alias 'libs:': 'libs/' }, // map tells the System loader where to look for things map: { // our app is within the app folder app: 'app', // angular bundles '@angular/core': 'libs:@angular/core/bundles/core.umd.js', '@angular/common': 'libs:@angular/common/bundles/common.umd.js', '@angular/compiler': 'libs:@angular/compiler/bundles/compiler.umd.js', '@angular/platform-browser': 'libs:@angular/platform-browser/bundles/platform-browser.umd.js', '@angular/platform-browser-dynamic': 'libs:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', '@angular/http': 'libs:@angular/http/bundles/http.umd.js', '@angular/router': 'libs:@angular/router/bundles/router.umd.js', '@angular/forms': 'libs:@angular/forms/bundles/forms.umd.js',

        // other libraries
        'rxjs': 'libs:rxjs',
        'ng2-uploader': 'libs:ng2-uploader'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
        app: {
            main: './main.js',
            defaultExtension: 'js'
        },
        rxjs: {
            defaultExtension: 'js'
        },
        'ng2-uploader':     { main: 'ng2-uploader.js', defaultExtension: 'js' },
    }
});

})(this); `

app.module.ts

`/// import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser';

import { UPLOAD_DIRECTIVES } from 'ng2-uploader/ng2-uploader';

import { AppComponent } from './app.component'; import { WelcomeComponent } from './welcome.component'; import { MonthComponent } from './month.component'; import { routing } from './app.routes';

@NgModule({ imports: [ BrowserModule, routing, CommonModule, FormsModule ], declarations: [ AppComponent, WelcomeComponent, MonthComponent, UPLOAD_DIRECTIVES ], entryComponents: [AppComponent], bootstrap: [AppComponent],

}) export class AppModule { }`

component using

`import { Component, OnInit, NgZone } from '@angular/core';

@Component({ selector: 'month', templateUrl: 'views/month.component.html' }) export class MonthComponent implements OnInit {

private fileUploader_Zone: NgZone;
private fileUploader_BasicOptions: Object;
private fileUploader_Progress: number;
private fileUploader_Response: any = {};

ngOnInit() {
    this.fileUploader_Zone = new NgZone({ enableLongStackTrace: false });
    this.fileUploader_BasicOptions = {
        url: 'http://api.ng2-uploader.com:10050/upload' };
}

handleUpload(data: any): void {
    this.fileUploader_Zone.run(() => {
        this.fileUploader_Response = data;
        this.fileUploader_Progress = data.progress.percent / 100;
    });
}

}`

`<input type="file" ngFileSelect [options]="fileUploader_BasicOptions" (onUpload)="handleUpload($event)">

Response: {{ response | json }}
Progress: {{ progress }}%
`
jkuri commented 8 years ago

Please make sure you include this module into NgModule.

Kbalz commented 8 years ago

Yes I think I have that, it is like this:

@NgModule({ imports: [ BrowserModule, routing, CommonModule, FormsModule ], declarations: [ AppComponent, WelcomeComponent, MonthComponent, UPLOAD_DIRECTIVES ],

Kbalz commented 8 years ago

I think my problem lies in the systemjs.config.js - can you please post how a proper reference should look? I know that may be outside of the scope for this project, but it may help as many of us learn Angular2 as well.

chrizy commented 7 years ago

Having the same issue using 2.0.0 release, with CLI (webpack). UPLOAD_DIRECTIVES is included in my app module.

oluosiname commented 7 years ago

Having same issue here as well

danielserrao commented 7 years ago

Same problem here

lipinets commented 7 years ago

I have the same. Please help to solve. Can't bind to 'options' since it isn't a known property of 'input'. (" <input type="file" ngFileSelect [ERROR ->][options]="basicOptions" (onUpload)="handleUpload($event)">

fxcosta commented 7 years ago

Same problem here!

Nogostradamus commented 7 years ago

Same problem. Angular version 2.1.0 (webpack)

joelflint commented 7 years ago

Same problem! Thx!

lipinets commented 7 years ago

Dear Developers, could you please advice us something or fix? A lot of people here with the same problem. Thank you!

MaxiSantos commented 7 years ago

Same issue here. Those ones who have this issue.. do you have more than 1 module in your app?

Nogostradamus commented 7 years ago

Just one module in my case.

lipinets commented 7 years ago

I have more then 1 module.

MaxiSantos commented 7 years ago

Ok, I think there is an issue here. First I thought the issue was related on how we are importing this Directive within the modules (I have more than one module and I thougth I was making some mistake there but based on some commets it looks the issue is present even with one module)

So I went to debbug the directive and I made this test. I removed the [options] attribute since the problem was there. Then I went to NgFileSelectDirective on ng-file-select.ts and set a breakpoint on

this.uploader.setOptions

And woala ! The breakpoint hit there so I think the directive is correctly imported, right? (because [options] does not longer exist you need to provide something there, otherwise it will complain later because of its undefined value)

After I set options to an empty object then I wanted to know if the event binding (onUpload) was correct or there were some issue there and it did work, it call my handler. Of course this didn't work because there was no url property.

Perhaps the way the options property is declared is somehow incorrect? It's using a getter/setter method.

NOTE: I'm using angular 2.2.0

Abinayats commented 7 years ago

Hi,

Thanks @MaxiSantos for the great solution. It works for me :)

VijayRidgeant commented 5 years ago

I got this error when i create echart . please solve

compiler.js:2426 Uncaught Error: Template parse errors: Can't bind to 'options' since it isn't a known property of 'div'. ("

User And Admin Commission Details

<div echarts [ERROR ->][options]="chartOption4" class="demo-chart" >

"): ng:///SampleModule/SampleComponent.html@10:13 at syntaxError (compiler.js:2426) at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:20600) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:26146) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:26133) at compiler.js:26076 at Set.forEach () at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:26076) at compiler.js:25986 at Object.then (compiler.js:2417) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:25985)

poojasharma1993 commented 4 years ago

you just need to import MatProgressButtonsModule as below

import { MatProgressButtonsModule } from 'mat-progress-buttons';