I've been attempting to change the view from the controller, but it's just not working properly.
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've tested a few options like the ones below, but none of them have worked so far:
$location.url('#/view2');
$location.url('/view2');
$location.path('/view2');
$location.path('#/view2');
However, inserting a link on a view page like this:
<a href="#/view2"</a>click
correctly routes the page. Any assistance with changing views from the controller would be greatly appreciated. Thanks in advance.