Skip to content

Instantly share code, notes, and snippets.

@dustintheweb
Created February 28, 2015 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustintheweb/7b07c4dca262b3eac4ae to your computer and use it in GitHub Desktop.
Save dustintheweb/7b07c4dca262b3eac4ae to your computer and use it in GitHub Desktop.
AngularJS: Toggle an external class from a click event inside of an include
<!doctype html>
<html ng-app="myApp">
<head>...</head>
<body ng-controller="myController" ng-class="toggleClass ? 'click-active' : 'click-inactive'">
<div ng-include="/path/myInclude.html"></div>
</body>
</html>
(function() { 'use strict';
var app = angular.module('myApp');
//
app.controller('mainCtrl',['$scope', function($scope){
$scope.toggleClass = false;
}]);
})();
<div>
stuff...
<div class="button" ng-click="$parent.toggleClass = !$parent.toggleClass"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment