Open asial-matagawa opened 7 years ago
My solution is create an component named ng-img
(NgImgComponent)
import {Component, Input} from '@angular/core';
@Component({
selector: 'ng-img',
template: `<img [attr.class]="class" [attr.src]="src" style="width: 100%; height: 100%">`
})
export class NgImgComponent {
@Input("src") src;
@Input("class") class;
constructor() { }
}
and then replace <img>
with <ng-img>
.
<ng-img class="pokemon-icon" src="./images/pokemon/icons/{{p.id}}.png"></ng-img>
With <ng-img>
, it not necessary to put ALL template to app.ts.
@andipavllo @erisu @frankdiox
Environment
Monaca CLI 2.1.7 monaca-lib 2.2.4
Encountered problem
The current webpack config for Angular 2 crashes with the following error when
foo.html
which is loaded byrequire('foo.html')
contains an unresolvable path (in asrc
attribute ofimg
element).How to reproduce
First, run the commands below:
Next, make this change in
src/app/app.html
:(This is required for running this app in Cordova environment. Otherwise, we would get the following error.)
Then, run the commands below:
FYI: If we use
template: (content of app.html)
instead oftemplate: require('./app.html')
, it worked fine on Cordova environment:But I think this is not a straightforward solution.