2015-09-16 82 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。 –