This is folder structure
\App_Plugins\ChannelSelection
channelselection.controller.js
channelselection.html
package.manifest
file contain
------------channelselection.controller.js--------------------
angular.module("umbraco")
.controller("My.ChannelSelectionController",
function ($scope) {
$.ajax({
url: "/umbraco/api/Portfolio/GetDropdownList",
dataType: "json",
type: "GET",
error: function () {
//alert(" An error occurred.");
},
success: function (data) {
console.log(JSON.stringify(data));
$('#fillvalues').find("option").remove();
var option = $("<option/>");
// option.attr("value", "").text("Select Channel");
$("#fillvalues").append(option);
$.each(data, function (i, product) {
$.each(product.Channel, function (j, productj) {
option = $("<option/>");
option.attr("value", productj.Id).text(productj.Name);
$("#fillvalues").append(option);
// contentc += ' <li><a href="' + productj.link + '"><img src="' + productj.Image + '" alt="' + productj.Name + '" /></a></li>';
});
});
$('#fillvalues').val($scope.model.value);
}
});
//alert('Control loaded');
});
--------------------channelselection.html-------------
<div ng-controller="My.ChannelSelectionController">
<select id="fillvalues" ng-model="model.value"></select>
</div>
--------------------package.manifest---------------
{
//you can define multiple editors
propertyEditors: [
{
/*this must be a unique alias*/
alias: "My.ChannelSelection",
/*the name*/
name: "Channel Selection",
/*the html file we will load for the editor*/
editor: {
view: "~/App_Plugins/ChannelSelection/channelselection.html"
}
}
]
,
//array of files we want to inject into the application on app_start
javascript: [
'~/App_Plugins/ChannelSelection/channelselection.controller.js'
]
}
\App_Plugins\ChannelSelection
channelselection.controller.js
channelselection.html
package.manifest
file contain
------------channelselection.controller.js--------------------
angular.module("umbraco")
.controller("My.ChannelSelectionController",
function ($scope) {
$.ajax({
url: "/umbraco/api/Portfolio/GetDropdownList",
dataType: "json",
type: "GET",
error: function () {
//alert(" An error occurred.");
},
success: function (data) {
console.log(JSON.stringify(data));
$('#fillvalues').find("option").remove();
var option = $("<option/>");
// option.attr("value", "").text("Select Channel");
$("#fillvalues").append(option);
$.each(data, function (i, product) {
$.each(product.Channel, function (j, productj) {
option = $("<option/>");
option.attr("value", productj.Id).text(productj.Name);
$("#fillvalues").append(option);
// contentc += ' <li><a href="' + productj.link + '"><img src="' + productj.Image + '" alt="' + productj.Name + '" /></a></li>';
});
});
$('#fillvalues').val($scope.model.value);
}
});
//alert('Control loaded');
});
--------------------channelselection.html-------------
<div ng-controller="My.ChannelSelectionController">
<select id="fillvalues" ng-model="model.value"></select>
</div>
--------------------package.manifest---------------
{
//you can define multiple editors
propertyEditors: [
{
/*this must be a unique alias*/
alias: "My.ChannelSelection",
/*the name*/
name: "Channel Selection",
/*the html file we will load for the editor*/
editor: {
view: "~/App_Plugins/ChannelSelection/channelselection.html"
}
}
]
,
//array of files we want to inject into the application on app_start
javascript: [
'~/App_Plugins/ChannelSelection/channelselection.controller.js'
]
}
No comments:
Post a Comment