This is hanging the browser. I believe I'm not returning data the right way and misunderstanding some concepts, perhaps a timing problem?
controller.js
export default class XController {
constructor($stateParams, YService) {
this.getSlugByName = function(name) {
return YService.get({name: name}).then(getSuccessFn, getFailFn);
function getSuccessFn(data) {
return data[0].slug;
}
function getFailFn() {
console.error('Something went wrong');
}
}
}
}
XController.$inject = ['$stateParams', 'YService'];
template.html
<ul>
<li ng-repeat="each in vm.mainObject.objects"> // each is a name
<a ui-sref="resolver({slug: vm.getSlugByName(each) })" class="btn">{{ each }}</a>
</ul>
routes.js
static resolver($stateParams, XService) {
return XService.get({ slug: $stateParams.slug });
}
component.js
import templateUrl from './template.html';
import controller from './controller';
let xComponent = {
restrict: 'E',
bindings: {
'mainObject': '<'
},
templateUrl: templateUrl,
controller,
controllerAs: 'vm'
};
export default xComponent;
Update
Added component file that explain where objects
bind is coming from