Created
August 15, 2017 13:01
-
-
Save perploug/2f0245c57dbfa96cef09fdec9dde3d41 to your computer and use it in GitHub Desktop.
complex editor sample code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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