2015-09-16 51 views
2

我想要获得一个简单的dojo模块来使用angular2。 但是,我无法加载angular2库和dojo库。 我试图加载道场先角然后反之亦然无济于事。这是我曾尝试:如何使用Dojo和Angular2

main.ts

/// <reference path="typings/dojo/dojo.d.ts"/> 
/// <reference path="typings/angular2/angular2.d.ts"/> 

import {Component, View, bootstrap} from 'angular2/angular2'; 

declare var require: (moduleId: string) => any; 
import dom = require("dojo/dom"); 
import fx = require("dojo/fx") 



@Component({ 
    selector: 'greeting' 
}) 
@View({ 
    template: `<div id="innergreeting">Hello From Angular and</div>` 
}) 
class DojoTest{ 
    constructor(){ 
     var greeting = dom.byId("innergreeting"); 
     greeting.innerHTML += ' Dojo!'; 
     fx.slideTo({ 
      node: greeting, 
      top: 100, 
      left: 200 
     }).play(); 
    } 
} 
bootstrap(DojoTest); 

的index.html

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"> 
    <title>Tutorial: Hello Dojo!</title> 

    <script src="https://github.jspm.io/jmcriffey/[email protected]/traceur-runtime.js"></script> 
    <script src="https://jspm.io/[email protected]"></script> 
    <script src="https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js"></script> 

    <script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script> 

</head> 

<body> 

    <greeting></greeting> 
    <script>System.import('main');</script> 

</body> 

</html> 

错误:

GET http://localhost:8080/dojo/dom.js 404(未找到)

GET http://localhost:8080/dojo/fx.js 404(未找到)

我对AngularJs相当新颖,所有帮助表示赞赏。

回答

0

GET http://localhost:8080/dojo/dom.js 404 (Not Found) GET http://localhost:8080/dojo/fx.js 404 (Not Found)

这是由下面的代码触发:

import dom = require("dojo/dom"); 
import fx = require("dojo/fx"); 

请确保您有dojo安装

+0

我应该包括还有什么其他比: 和 /// ? – Andrew

+0

'jspm install dojo'并移除'script'标记 – basarat

+1

我想如果需要,还应该可以配置SystemJS加载器从CDN的Dojo包加载模块。对于AMD装载机,通常会使用'packages'或'paths',但它看起来可能是['map'](https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#地图)更适合于SystemJS。 –