Get Global Nav using http get method
-
09-12-2020 - |
Pregunta
How can I get global navigation into my angularApp
using $http
get method in angularJs.
Does sharepoint store global navigation in any List? Then I can get it by using $http get
method.
I tried @gautam's answer/code but it's didn't work for me, I got following data
[{
"CustomProperties": {
"__metadata": {
"type": "Collection(SP.KeyValue)"
},
"results": []
},
"FriendlyUrlSegment": "test-1",
"IsDeleted": false,
"IsHidden": false,
"Key": "2e0787a2-773d-418f-90e1-03a903c08563",
"Nodes": "__metadata": {
"type": "Collection(SP.MenuNode)"
},
"results": []
},
"NodeType": 1,
"SimpleUrl": "",
"Title": "Test 1"
}]
Solución
You can get the global navigation in angular like below:
var myAngApp = angular.module('SharePointAngApp', []);
myAngApp.controller('spController', function ($scope, $http) {
$http({
method: 'GET',
url: _spPageContextInfo.webAbsoluteUrl + "/_api/navigation/menustate?mapprovidername='GlobalNavigationSwitchableProvider'",
headers: { "Accept": "application/json;odata=verbose" }
}).success(function (data, status, headers, config) {
$scope.results = data.d.MenuState.Nodes.results;
}).error(function (data, status, headers, config) {
});
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a sharepoint.stackexchange