私には指令とコントローラがあります。休閑としてディレクティブ:角度指令とコントローラ
calcP.directive('modalDialog', function() {
return {
restrict: 'E',
scope: {
show: '='
},
replace: true,
transclude: true,
link: function(scope, element, attrs) {
scope.dialogStyle = {};
if (attrs.width)
scope.dialogStyle.width = attrs.width;
if (attrs.height)
scope.dialogStyle.height = attrs.height;
**scope.hideModal = function() {
scope.show = false;
delete $sope.types.individual;**
};
},
template: "..."
};
});
マイコントローラ:
calcP.controller('calcPCtrl', function($scope, $http, $window, emailSenderEndpoint) {
$scope.getVariantDomovoy = function() {
$scope.types.domovoy = $scope.variants.domovoy;
};
$scope.getVariantIndividual = function() {
$scope.types.individual = $scope.variants.individual;
};
...
$scope.modalShown = false;
$scope.toggleModal = function() {
$scope.modalShown = !$scope.modalShown;
};
});
マイテンプレート:
template: "<div class='ng-modal' ng-show='show'><div class='ng-modal-overlay' ng-click='hideModal()'></div><div class='ng-modal-dialog' ng-style='dialogStyle'><div class='ng-modal-close' ng-click='hideModal()'>X</div><div class='ng-modal-dialog-content' ng-transclude></div></div></div>"
私は機能に追加して、いくつかの$スコープを削除したいと思います。しかし、ブラウザは変数$ scope.types.individualが見つからないというエラーを表示します。
私は自分自身でAangularJSを学習しようとしていますが、まだいくつか問題があります。
'$ sope.types.individualを削除し、このようにすることができ、' ??または 'delete $ scope.types.individual;' ?? – DilumN
私が正しく理解しているように、あなたの 'types'はあなたのコントローラにありますか?だからあなたは '$ scope. $ parent.types.individual;を削除することができますが、それはあなたが何かを達成しようとしていると思われます。 – devqon
@DilumNはい、$ scope、申し訳ありません。まだ同じエラーがあります –