Skip to content

Instantly share code, notes, and snippets.

@perploug
Created August 15, 2017 13:01
Show Gist options
  • Save perploug/2f0245c57dbfa96cef09fdec9dde3d41 to your computer and use it in GitHub Desktop.
Save perploug/2f0245c57dbfa96cef09fdec9dde3d41 to your computer and use it in GitHub Desktop.
complex editor sample code
angular.module("umbraco").controller("my.forumsearcher.controller",
function ($scope, $http) {
if (angular.isArray($scope.model.value) === false) {
$scope.model.value = [];
}
$scope.add = function (result) {
$scope.model.value.push(result);
}
$scope.search = function (term) {
var url = "https://our.umbraco.org/umbraco/api/OurSearch/GetForumSearchResults?term=" + term;
$http.get(url).then(function (response) {
$scope.model.results = response.data.items;
}, function (error) {
alert(error);
});
};
});
<div ng-controller="my.forumsearcher.controller">
<input type="text" class="span9"
ng-model="model.term"
ng-keyup="search(model.term)" />
<ul>
<li ng-repeat="result in model.results">
<a href ng-click="add(result)">
{{result.Fields.nodeName}}
</a>
</li>
</ul>
<h4>Currently stored forum posts:</h4>
<ul>
<li ng-repeat="result in model.value">
{{result.Fields.nodeName}}
</li>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment