I attached sample app with little description.
download
All stuff is already described OK on this link: http://2sxc.org/en/blog/post/configurable-custom-input-type-dynamic-data-content
I just change this sample to use string and main code change is in angular controller and my code look like this:
var url;
var controlSettings = $scope.to.settings["string-nn-json-list"];
if (controlSettings) url = controlSettings.jsonUrl || null;
// if null set default apiUrl
if (url === null) url = "http://www.mocky.io/v2/57aae03e120000be10739d3b";
$http({
method: 'GET',
url: url,
headers: {
'TabId': undefined,
'Pragma' : undefined,
'RequestVerificationToken' : undefined,
'Cache-Control' : undefined,
'Debugging-Hint' : undefined,
'ContentBlockId' : undefined,
'ModuleId' : undefined,
}
}).then(function successCallback(response) {
$scope.json_list_data = response.data;
});
For external json api data I use this : http://www.mocky.io/v2/57aae03e120000be10739d3b created on www.mocky.io and this is the default jsonUrl for "string-nn-json-list". You can change this url in field settings.
EDIT(1)
I trying get moduleId with help of iid into controller but with no luck..
(function() {
"use strict";
angular.module("nnStringFromIntJsonData", [])
.config(function(formlyConfigProvider, defaultFieldWrappers) {
})
.controller("FieldTemplate-String-Nn-Int-Json-List", function($scope, $filter, $modal, appId, debugState, eavAdminDialogs, $http) {
// What to change in this code
// that I can get iid (moduleId) in this part of code?
debugger;
})
.run(
function($templateCache) {
})
})();
What I must change (add) to this code that iid is accessible?
EDIT(2)
One way but with lost of security (I use only for read not important data) is that way you remove Api controller attributes :
[DnnModuleAuthorize] and [ValidateAntiForgeryToken] and leave only [HttpGet]
and when calling from custom input type controller use something like :
var url = "/DesktopModules/2sxc/API/app-api/{ControllerName}/{MethodName}";
$http.get(url).then(function successCallback(response) {
$scope.json_list_data = response.data;
});
I realy don't know what I am doing... It seems that more I learn less I know :-( and code with try/error system to get something partly usible...