javascript - How to apply the Location.url() that I changed -


i trying angular redirect have got part of way. @ moment have managed change url want go url instead of changing it.

    scope.socialreturnurl = function ( path ) {       location.url( path + 'assessment' );     }; 

my below code seems change url or location. missing apply gets redirected?

i should point out i've tried use scope$apply() causes below error:

scope$apply not defined

i have scope dependency havent got apply dependency need?

let me know thoughts!

you need inject $location service in controller in order change url. if don't, you'll calling window.location object instead, not should doing.

var app = angular.module('myapp'); app.controller('mycontroller',     ['$scope', '$location',     function($scope, $location) {         $scope.socialreturnurl = function ( path ) {             $location.url( path + 'assessment' );         };     }]) 

Comments