2

I have ASP.NET application where we use AngularJS. The issue is when we click "edit" the new view is openinig in the same window (tab). How to open it in new window (tab)? Here's the code:

List.html:

<td><a ng-click="editUser(u.ID)">edit</a></td>

AngularJS:

AdminUsersApp.controller("ListController", function ($scope, $location, $http, ErrorUI, Users, Cashdesks) {

...


$scope.editUser = function (id) {
    $location.path("/edit/" + id);
};
7
  • Did you try window.open("/edit/" + id); Commented Feb 18, 2015 at 7:05
  • Possible duplicate of stackoverflow.com/questions/20099784/… Commented Feb 18, 2015 at 7:08
  • @Nilesh: It doesn't work because there is some path got by $location.path. Commented Feb 18, 2015 at 7:15
  • If you have to show a different HTML file then use window.open. What is `/edit/' + id; is it a URL to some different html? Commented Feb 18, 2015 at 7:44
  • 1
    $location.path just returns the path of current page. instead you need the url which actually points to a different location, so when you call window s open function it should have window.open('example.com/admin/Admin_Users.aspx#/edit/id'). If you want to build the url dynamically use $location.host(), $location.protocol() etc to build a url and then append /edit/id at the end. Commented Feb 18, 2015 at 8:18

2 Answers 2

0

$location.path just returns the path of current page. instead you need the url which actually points to a different location, so when you call window s open function it should have window.open('example.com/admin/Admin_Users.aspx#/edit/id'). If you want to build the url dynamically use $location.host(), $location.protocol() etc to build a url and then append /edit/id at the end

Sign up to request clarification or add additional context in comments.

Comments

0

this work for me

$window.open(url);

1 Comment

What should be url in my case?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.