Created
February 28, 2015 11:14
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { 'use strict'; | |
var app = angular.module('myApp'); | |
// | |
app.controller('mainCtrl',['$scope', function($scope){ | |
$scope.toggleClass = false; | |
}]); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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