templates - Angularjs. Open content in new tab -
i've read similar questions/answers on so, can't resolve problem. here setup: index.html
<li ng-repeat="a in article"> <a ng-click="articledetails(a.id)"> {{a.title_en}} </a> </li>
js file
angular.module('myapp.article', ['ngroute']) .config(['$routeprovider', '$locationprovider', function ($routeprovider, $locationprovider) { $routeprovider.when('/article/:id', { templateurl: 'article/article.html', controller: 'articledetailctrl' }); //$locationprovider.html5mode(true); }]) .controller('articledetailctrl', ['$http', '$routeparams', '$scope', '$window', '$location', function ($http, $routeparams, $scope, $window, $location) { $scope.params = 'blabla'; }])
article.html
<div>{{params}}</div>
question: when click link in index.html new tab opened expected correct url, however, instead of article details not found on webpage. might problem?
edit 1: function articledetail defined follows in controller used in index.html:
$scope.articledetails = function (id) { $scope.id = id; $scope.window = $window.open('article/' + id, '_blank'); }
you cannot retain scope of angular application in window. hence calling $window.open
open new window not have original $scope
.
the scope tied window in ngapp
initialized.
in order overcome this, can use localstorage
of browser.
edit: please refer this
Comments
Post a Comment