Hello, I started studying Angular not so long ago. Now there is a problem: there is a block on the page
<div ui-view="probe_content" autoscroll="false"></div> In which the data from json is loaded by clicking on the link
<a ui-sref="restricted.probes.details({ probeId:probes.id})">{{probes.name}}</a> The link is in ng-repeat .
Everything works fine, by clicking on the link I get the record id and through the state url: "/ details / {itemId: [0-9] {1,4}}" I load the template with detailed information, but I also need to load the detailed information first item when loading the main page.
Those. Visited the page we see not an empty template with a list of links on which you need to click, but a list of links and the same detailed information of the first element by default.
Help, please, to understand the problem!
Below is the connection code.
index.html : (list of links)
<li ng-repeat="probes in menu.probe_list" ui-sref-active="md-list-item-active"> <a ui-sref="restricted.probes.details({ probeId:probes.id})"> {{probes.name}} </a> </li> index.html : (block for template connection)
<div ui-view="probe_content" autoscroll="false"></div> The states.js file:
.state("restricted.probes", { url: "/probes", templateUrl: path_prefix + 'app/components/probes/probesView.html', controller: 'probesCtrl', resolve: { deps: ['$ocLazyLoad', function($ocLazyLoad) { return $ocLazyLoad.load( path_prefix + 'app/components/probes/probesController.js'); }], probes: function($http){ return $http({ method: 'POST', url: '/api/probe/submenu/' }) .then(function (data) { return data.data; }); } }, data: { pageTitle: 'Пробы' } }) .state("restricted.probes.details", { url: "/details/{probeId:[0-9]{1,4}}", views: { 'probe_content': { templateUrl: path_prefix + 'app/components/probes/probe_detailView.html', controller: 'probesCtrl' } }, params: { hidePreloader: true } }) I think you need to check if the probeId parameter probeId not present, then redirect to a page with a detailed description of the first element. But I don’t know how to do a check and how to do a redirect .. Please write an example.