I'm trying to change view from the controller but it isn't working.
app.js
var app = angular.module('vla', ['ngRoute']);
app.config(function ($routeProvider){
$routeProvider
.when('/view1',
{
controller: 'loginController',
templateUrl: 'partials/loginView.html'
})
.when('/view2',
{
controller: 'noteController',
templateUrl: 'partials/videoView.html'
})
.when('/view3',
{
controller: 'videoListController',
templateUrl: 'partials/videoListView.html'
})
.otherwise({ redirectTo: '/view1' });
});
view: videoListView.html
<div class="video" data-ng-click="selectVideo(video)" ng-repeat="video in videos">
<div ng-repeat="(key, val) in video|orderBy:orderByField:videoName">
{{key}}: {{val}} </br>
</div>
</div>
controller.js
app.controller('videoListController', function($scope,getVideoListService){
$scope.selectVideo = function(video){
$location.url('/view2');
}
});
I have tried the following but none seem to work
$location.url('#/view2');
$location.url('/view2');
$location.path('/view2');
$location.path('#/view2');
When inserting a link on a view page such as
<a href="#/view2"</a>click
the page is correctly routed, would appreciate any help on changing views from the controller.
Thanks in advance