Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System is not defined at Object.<anonymous> (angular2-image-popup\directives\angular2-image-popup\image-modal-popup.js) #11

Open
Nikolay-Uvarov opened this issue Dec 15, 2016 · 0 comments

Comments

@Nikolay-Uvarov
Copy link

Can you help me solve the problem?
app.module.ts

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { UniversalModule } from 'angular2-universal';
import { AppComponent } from './components/app/app.component'
..
import { PhotosComponent } from './components/photos/photos.component';
import { Title } from '@angular/platform-browser';
import { ImageModal } from 'angular2-image-popup/directives/angular2-image-popup/image-modal-popup';

@NgModule({
    bootstrap: [ AppComponent ],
    declarations: [
        AppComponent,
        PhotosComponent,
        ImageModal,
        ..
    ],
    imports: [
        FormsModule,
        TextMaskModule,
        UniversalModule, // Must be first import. This automatically imports BrowserModule, HttpModule, and JsonpModule too.
        ImageUploadModule,
        RouterModule.forRoot([
            { path: '', redirectTo: 'home', pathMatch: 'full' },
            { path: 'photos', component: PhotosComponent },
            { path: 'Account/Logout', redirectTo: "/Account/Logout" },
            ..
            { path: '**', redirectTo: 'home' }
        ])
    ],
    providers: [Title],
})
export class AppModule {
}

photo.componnt.ts

import { Component } from '@angular/core';
import { Http } from '@angular/http';

@Component({
    selector: 'photos',
    template: require('./photos.component.html')
})
export class PhotosComponent {
    public photos: IPhoto[];

    constructor(http: Http) {
        http.get('/api/SampleData/Photos').subscribe(result => {
            this.photos = result.json();
        });
    }

    openModalWindow: boolean = false;
    imagePointer: number;
    images = [
        { thumb: './Files/Photo1.jpg', img: './Files/Photo1', description: 'Image 1' },
        { thumb: './Files/Photo2.jpg', img: './Files/Photo2', description: 'Image 2' },
        { thumb: './Files/Photo3.jpg', img: './Files/Photo3', description: 'Image 3' },
       ];

    OpenImageModel(imageSrc, images) {
        //alert('OpenImages');
        var imageModalPointer;
        for (var i = 0; i < images.length; i++) {
            if (imageSrc === images[i].img) {
                imageModalPointer = i;
                console.log('jhhl', i);
                break;
            }
        }
        this.openModalWindow = true;
        this.images = images;
        this.imagePointer = imageModalPointer;
    }
    cancelImageModel() {
        this.openModalWindow = false;
    }

}

interface IPhoto {
    id: number;
    path: string;
    name: string;
}

photo.component.html

<p *ngIf="!photos"><em>Loading...</em></p>
<div *ngIf="photos">
    <p> you can directly access "ImageModel" directive for both listing thumbnails and popup images</p>
    <ImageModal [modalImages]="images"></ImageModal>
    <div *ngIf="openModalWindow">
        <ImageModal [modalImages]="images" [imagePointer]="imagePointer" (cancelEvent)="cancelImageModel()"></ImageModal>
    </div>
</div>

stack_image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant