0
我正在使用angular + requirejs,並且希望使它與打字稿一起工作。 如何在腳本中編寫腳本?Requirejs Angular和TypeScript
HomeController1.js
define(['controllers/controllers'],
function (controllers) {
controllers.controller('HomeController',
['$window',
'$scope',
function (
$window,
$scope) {
$scope.showSubRouting = true;
}
]);
});
Controllers1.js
define(['angular'], function (angular) {
'use strict';
return angular.module('controllers', []);
});
我嘗試這樣做:
HomeController2.ts
import controllers = require("controllers/controllers");
class HomeController {
showSubRouting: boolean = false
constructor() {
}
}
個
Controllers2.ts
import angular = require("angular");
angular.module("controllers", []);
但控制器的定義中缺少HomeController2.js (define(['controllers/controllers']
)
HomeController2.js
define(["require", "exports"], function (require, exports) {
var HomeController = (function() {
function HomeController() {
this.showSubRouting = false;
}
return HomeController;
})();
});
難道你們知道我在做什麼錯誤?
在此先感謝
這就是答案謝謝sooo多!!! 1 –