This Rails project using Webpacker with Angular
Clone the git repo
git clone https://github.com/rkugot/rails-angular-training.git
cd rails-angular-training
Install dependencies
bundle install
yarn install
Setup db
bundle exec rake db:create db:migrate
Start rails and webpack servers using Foreman
foreman start
Require this file to component using template
instead of templateUrl
:
import { Component } from '@angular/core';
@Component({
selector: 'hello-angular',
template: require('./app.component.html'),
})
export class AppComponent {}
Require this file to component using styles
instead of styleUrls
and serve it as a string:
import { Component } from '@angular/core';
@Component({
selector: 'hello-angular',
styles: [require('./app.component.css').toString()],
})
export class AppComponent {}
Add ['app/assets']
to resolved_paths
in webpacker.yml
and you can serve images in component template this way:
<img class="logo" src="assets/images/logo.png" >