javascript - Trying to generate a button-group with Bootsrap and AngularJS to redirect to different URLs -
i trying create button group of 2 (using bootstrap , angularjs) that, when clicking on them, each redirect different url. have following code (copied relevant pieces):
app.controller('linkcontroller',function(link, $scope, $location){ $scope.go = function(){ $location.url(link); }; }); <div class="btn-group btn-group-lg" data-ng-controller = "linkcontroller"> <button type="button" class="btn btn-primary" data-ng-click = "go('test1.html')">click1</button> <button type="button" class="btn btn-primary" data-ng-click = "go('test2.html')">click2</button> </div> however, doesn't work, , not sure why. might not passing arguments correctly, tried without passing link , still didn't work. appreciate help!
are trying pass url ?, if so, :
app.controller('linkcontroller',function(link, $scope, $location){ $scope.go = function(link){ $location.url(link); }; }); <div class="btn-group btn-group-lg" data-ng-controller = "linkcontroller"> <button type="button" class="btn btn-primary" data-ng-click = "go('test1.html')">click1</button> <button type="button" class="btn btn-primary" data-ng-click = "go('test2.html')">click2</button> </div>
Comments
Post a Comment