A newbie question regarding Angular & the backoffice:
I've created a custom section with a tree. When I click an item on the tree it loads the Url: /umbraco#/myCustomSection/myCustomSectionTree/edit/{id}
All loads perfectly, html / angular controller, but in my angular controller, how do I get the {id} value so that I can call my API controller and get the correct data that I want to display?
As part of the angular controller, you can add in $routeParams as a property that can be injected. That then has an id field which you can use to pass to the API endpoint/resource factory. An example for a custom section we have in our sites is:
function tVTreeController($scope, $http, $routeParams, umbRequestHelper, tVTreeResources, tVResources) {
var vm = this;
vm.id = $routeParams.id;
vm.search = '';
function init() {
tVTreeResources.getItem(vm.id).then(function (results) {
if (results.folder !== null) {
vm.view = 'folder';
vm.folder = results.folder;
} else {
vm.view = 'video';
vm.video = results.video;
}
});
}
init();
}
I have the if, as the tree is made up of 2 types of items.
Extending the backoffice - Angular
Hi,
A newbie question regarding Angular & the backoffice:
I've created a custom section with a tree. When I click an item on the tree it loads the Url: /umbraco#/myCustomSection/myCustomSectionTree/edit/{id}
All loads perfectly, html / angular controller, but in my angular controller, how do I get the {id} value so that I can call my API controller and get the correct data that I want to display?
Thanks.
Mark
Hi Mark,
As part of the angular controller, you can add in
$routeParams
as a property that can be injected. That then has an id field which you can use to pass to the API endpoint/resource factory. An example for a custom section we have in our sites is:I have the if, as the tree is made up of 2 types of items.
Hope this helps
Kind Regards, Ben
is working on a reply...