0
일부 지시문은 매우 유사하지만 다른 지시문은 매우 다릅니다. 중복 코드 상속의 양을 줄이기 위해, 그러나 아직 지시어 클래스를 인스턴스화하는 방법을 알지 못했습니다.Typescript 클래스로 구현 된 AngularJs 지시문 등록
/// <reference path='../_all.ts' />
module app.directives {
'use strict';
export class myDirective implements ng.IDirective
{
private margin = {top: 70, right: 20, bottom: 40, left: 55};
private padding = {top: 10, right: 10, bottom: 10, left: 10};
public restrict = 'A';
public $scope = {
regulationdata: "=",
title: "="
};
constructor(private $window) {}
public link($scope, element: JQuery, attr: ng.IAttributes)
{
// Browser onresize event
this.$window.onresize = function() { // TypeError: Cannot read property '$window' of undefined
$scope.$apply();
};
// lots of application specific code.
}
}
/** Register directive */
angular.module('app').directive('myDirective',['$window', ($window) => { return new myDirective($window); });
}
I 나타나는 오류는 다음과 같습니다 : TypeError: Cannot read property '$window' of undefined
감사합니다, 링크에서 비디오, 당신은 추가 문제를 설명하기 위해 정말 좋은 것입니다. – CodeTower
예,이 비디오는 정말 좋았습니다. 인터셉터와 동일한 문제가있었습니다 ... – boindiil
완전성을 위해 : https://www.youtube.com/watch?v=tvocUcbCupA&hd=1 – CodeTower