在父范围内编译元素

时间:2016-01-14 17:34:37

标签: angularjs angularjs-directive

我有两个指令。如果需要,第一setPreviewCallbackWithBuffer()遍历检查中的所有元素,如果是,则添加*和某些css等。

第二个mark-required动态需要输入字段,我需要它因为diff。用户输入有差异。必填项目。

我得到第二个指令与flexible-required一起使用,但来自父范围的指令,例如compile会被忽略。

指令mark-required

flexible-required
  • 答:如果我在那个地方添加angular.module 'tsd.flexibleRequired', ['ui.bootstrap.showErrors'] .directive 'flexibleRequired', ($http, $rootScope, implantsService) -> return { restrict: 'A' scope: isRequired: '=' controller: ($scope, $element, $compile) -> compileElement = $element[0] # compileForm = angular.element(document).find('form')[0] #B $scope.$watch('isRequired', (newValue, oldValue)-> if newValue != oldValue if newValue == true compileElement.required = true else compileElement.required = false $compile(compileElement)($scope) #A # $compile(compileForm)($scope.$parent) #B ) return } 没有任何反应
  • B:如果我取消注释下面的行,它确实有效,但我的所有输入都被编译,我只想在我的父作用域中编译这个特定的元素。

HTML

$scope.$parent

问题:

我怎样才能在父范围内编译<form name="patientDataForm" ng-submit="save()" mark-required> ... <div class="form-group col-lg-6" show-errors> <label>Versicherungsnummer/Krankenkasse</label> <input type="text" class="form-control" name="insurance" ng-model="registerPatientController.patientData.insurance" placeholder="Versicherungsnummer oder Krankenkasse" ng-pattern="/^[0-9].*$/" is-required="registerPatientController.patientData.sendToEprd"flexible-required enter-to-tab/> <p class="help-block" ng-if="patientDataForm.insurance.$error">Ihre Versicherungsnummer/Krankenkasse wird benötigt!</p> </div>

0 个答案:

没有答案
相关问题