You don't, it will make the connection for you. Just put ng-view somewhere in the html below the navbar, the link click will be caught by angular, then look at your config and decide what template/controller to load at the point of ng-view element. (consider using html5mode: $locationProvider.html5Mode(true).hashPrefix('!');)
<body ng-controller='MainCtrl'> <nav><a href="/home"></a><a href="/contact"></a?</nav> <div ng-view></div> </body> $routeProvider .when('/home', { templateUrl: '/partials/home.html', controller: 'HomeCtrl' }) .when('/contact', { templateUrl: '/partials/contact.html', controller: 'HomeCtrl' }); So if you were to use an actual <button> element, just change the location... <button ng-click="goto('/home')">Home</button> .controller('MainCtrl', ['$scope', '$location', function($scope, $location){ $scope.goto = function(link){ $location.path(link); //this just changes the URL for you the same as clicking a link } } On Tuesday, April 28, 2015 at 11:44:43 AM UTC-6, Mariusz Wilk wrote: > > I'm new to programming and I'm trying to built my first simple website but > I'd like to use some Angular.js. > So when I click a button on the navbar I'd like the view and the > controller to change. The way I understood it from the Codecademy course I > could > use app.config(function($routeProvider){...}) and depending on what's > added to the Url the view and controller changes (but the navbar doesn't). > That way I define a clear link between a Url and content. But where's the > link between the navbar button and the Url? How do I bind these two? > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.