Recently, I delved into the world of Angular2 and decided to experiment with some animations using css-animator
package.json
"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/forms": "0.1.1",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/router": "3.0.0-alpha.7",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.3",
"angular2-in-memory-web-api": "0.0.12",
"bootstrap": "^3.3.6",
"chokidar": "^1.6.0",
"core-js": "^2.4.0",
"css-animator": "^1.2.4",
"http-proxy": "^1.14.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.27",
"zone.js": "^0.6.12"
}
index.html
<html>
<head>
<title>Angular 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="app/css/bootstrap.css">
<link rel="stylesheet" href="app/css/style.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/css-animator/builder/animation_builder.js"> </script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body class="bg-image">
<my-app>Loading...</my-app>
</body>
</html>
systemjs.config.js
var map = {
'app': 'app', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs',
'css-animator': 'node_modules/css-animator'
};
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
};
System.config(config);
custom.animate.directive.ts
import {Directive, ElementRef, Renderer} from '@angular/core';
import {AnimationService, AnimationBuilder} from 'css-animator';
@Directive({
selector: '[login-method]',
host: {
'(click)':'onClick()'
}
})
export class LoginOptionsDirective{
private animator : AnimationBuilder;
constructor(animationService: AnimationService, private el: ElementRef, private renderer: Renderer){
this.animator = animationService.builder();
}
onclick(){
this.renderer.setElementStyle(this.el, 'color','black');
console.log(this.el.nativeElement.getAttribute("login-method"));
}
}
I encountered errors like
animation_builder.js:434 Uncaught ReferenceError: exports is not defined
and localhost/:18 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/css-animator(…)
on the browser console.
Seeking assistance to resolve these issues. Any help would be much appreciated!
Thank you.