Skip to content

Instantly share code, notes, and snippets.

@abruzzi
Created December 31, 2013 14:25
Show Gist options
  • Save abruzzi/8197485 to your computer and use it in GitHub Desktop.
Save abruzzi/8197485 to your computer and use it in GitHub Desktop.
nested views in angularjs
var app = angular.module('MyApp');
app.controller('ContactController', ['$scope', function($scope) {
$scope.contacts = ["juntao", "abruzzi"];
$scope.submit = function() {
$scope.$parent.toggleContactsPanel();
};
}]);
<div ng-controller='ContactController'>
<ul ng-repeat='contact in contacts'>
<li>{{contact}}</li>
</ul>
<input type="button" ng-click="submit()" value="submit" />
</div>
var app = angular.module('MyApp');
app.controller("MainController", ['$scope', funciton($scope) {
$scope.showContacts = false;
$scope.toggleContactsPanel = function() {
$scope.showContacts = !$scope.showContacts;
};
}]);
<span ng-click="toggleContactsPanel()">Click to show contacts</span>
<div ng-include="'views/contacts.html'" ng-show="showContacts">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment