I am trying to add class to parent item with angularjs. I am new to angular and little ok with jquery. Is there any specific way to add border to the parent of parent span when there is a ng-change for a textbox control. This scenario came to me as I am trying to use a kendo date picker inside a ng-repeat and have to add a red border to control if there is any validation error. Telerik kendo datepicker adds a span as parent to textbox. so adding border color red to textbox doesnt make any sense and it has to be a border red for dynamically added parent span for kendo datepicker. I am trying to make this generic so that the same can be used through out my application.
Here is my fiddle
<div ng-controller="MyCtrl">
<span class="k-widget k-datepicker k-header" ng-class={{classValidationControl}} style="border: solid">
<span class="k-picker-wrap k-state-default">
<input type="text" kendo-date-picker="" id="endDateTextbox-0" ng-change="addBorderToControl('endDateTextbox-0')">
<span>
<span unselectable="on" class="k-icon k-i-calendar">
select
</span>
</span>
<span class="k-widget k-datepicker k-header" ng-class={{classValidationControl}} style="border: solid">
<span class="k-picker-wrap k-state-default">
<input type="text" kendo-date-picker="" id="endDateTextbox-1" ng-change="addBorderToControl('endDateTextbox-0')">
<span>
<span unselectable="on" class="k-icon k-i-calendar">
select
</span>
</span>
</div>
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.addBorderToControl = function(controlName) {
$('#' + controlName).element.parent().parent().addClass("validationControl");
}
}
MyCtrlnot calling. i just alertedcontrolNamebut nothing happened