Created
December 31, 2013 14:25
-
-
Save abruzzi/8197485 to your computer and use it in GitHub Desktop.
nested views in angularjs
This file contains 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
var app = angular.module('MyApp'); | |
app.controller('ContactController', ['$scope', function($scope) { | |
$scope.contacts = ["juntao", "abruzzi"]; | |
$scope.submit = function() { | |
$scope.$parent.toggleContactsPanel(); | |
}; | |
}]); |
This file contains 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 ng-controller='ContactController'> | |
<ul ng-repeat='contact in contacts'> | |
<li>{{contact}}</li> | |
</ul> | |
<input type="button" ng-click="submit()" value="submit" /> | |
</div> |
This file contains 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
var app = angular.module('MyApp'); | |
app.controller("MainController", ['$scope', funciton($scope) { | |
$scope.showContacts = false; | |
$scope.toggleContactsPanel = function() { | |
$scope.showContacts = !$scope.showContacts; | |
}; | |
}]); |
This file contains 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
<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