At the moment it's a not easy task.
I have try it with AngularCli. I have created a new project using ng new
and I have follow this steps:
ng new kframetest
Install aframe
and aframe-template-component
using:
npm install aframe aframe-template-component --save
Due to both (zone.js and A-frame) catch attributeChangedCallback
you need to load A-frame before zone.js. Then (in polyfills.ts
file) I have added:
import 'aframe';
import 'aframe-template-component';
Just before of import 'zone.js/dist/zone';
Create a simple component using kframe sample as template.
In order to Angular can parse specials html tags like <a-entity>
you have to add a CUSTOM_ELEMENTS_SCHEMA
and NO_ERRORS_SCHEMA
to NgModule
using schemas
property:
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
Run the application.
Now you can see, in the console, A-frame running:
Put the A-Frame script
tag in the head
of the HTML before the scene to ensure everything for A-Frame is properly registered before they are used from HTML.
aframe-master.js:75646 A-Frame Version: 0.5.0 (Date 10-02-2017, Commit #bf8b8f9)
aframe-master.js:75647 three Version: ^0.83.0
aframe-master.js:75648 WebVR Polyfill Version: dmarcos/webvr-polyfill#a02a8089b
But the big problem is that Angular tryes to parse the HTML and he don't understand the aframe template syntax, you get this errors:
Unhandled Promise rejection: Template parse errors:
Parser Error: Unexpected token #
at column 6 in [src: #boxesTemplate]
in KFrameTestComponent
</a-assets>
<a-entity [ERROR ->]template="src: #boxesTemplate"
data-box1color="red" data-box2color="green" data-box3color"): KFrameTestComponent@10:12
Property binding src
not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the @NgModule.declarations
.
</a-assets>
I have been searching about add html without Angular parse it but I didn't find ...
I have tried to add the template to the index html and it seems to work but I understand that is not your desired situation.
You can get the code from here: https://gitlab.com/jros/angularcli-kframe