Spent some time searching for an answer to this, grabbed a few lines of different sample code and it just errors out as well.
Goal:
Click a button > button adds class "active" to a div. Inside the div.active there is another element with a function to remove .active from div.active
HTML:
<body ng-app="myApp">
<div ng-controller="myCtrl">
<button ng-click="slidePanel='active'">Open Div 1</button>
<div class="div1" ng-class="slidePanel">
<div class="close" ng-click="removeActive()">Close</div>
Hi I'm a Slide Panel
</div>
</div>
</body>
JS:
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function ($scope) {
$scope.removeActive = function () {
//Errors with Element is not defined
/*var myEl = angular.element(element.getElementsByClassName('div1'));
myEl.removeClass('active');*/
//Errors with myEl.removeClass is not a function
var myEl = document.getElementsByClassName('div1');
myEl.removeClass('active');
//Errors with [jqLite:nosel] Looking up elements via selectors is not supported by jqLite!
/*var myEl = angular.element('div1');
myEl.removeClass('active');*/
//Errors with Element is not defined
/*var query = element[0].querySelector('.div1');
var wrappedQueryResult = angular.element(query);
query.removeClass('active');*/
}
}]);
Not sure what I'm doing wrong here.