谁能纠正我在这里做的事情
Uncaught TypeError: Object function DataService($scope) {
this.$scope = $scope;
// Members Area
var addVessel = function (userId) {
alert("user"+userId);
};
} has no method 'addVessel'
非常感谢 - 我是新手
在查看回复后,似乎问题嵌套得更高
这是命名空间/类
// Member Service Namespace
var MemberService;
(function (MemberService) {
// Member service type
var DataService = (function ($scope) {
// Construct the data service
function DataService($scope) {
this.$scope = $scope;
// Members Area
this.addVessel = function (userId) {
alert("user"+userId);
};
}
return DataService;
})();
MemberService.DataService = DataService;
})(MemberService || (MemberService = {}));
这就是电话
MemberService.DataService.addVessel('XXX');