The custom section view button submit cannot be called addtags api on the first request, but can be called on the second request.
<div ng-controller="DamTagsController">
<input type="text" ng-model="newTag" placeholder="Add tag">
<button ng-click="addTag()">Add</button>
<ul>
<li ng-repeat="tag in tags">{{tag.Tag}}</li>
</ul>
</div>
angular.module("umbraco").controller("DamTagsController", function ($scope, $http, $routeParams) {
$scope.newTag = "";
$scope.tags = [];
$scope.addTag = function () {
$scope.addTag = function () {
var data = {
mediaId: $routeParams.id,
tag: $scope.newTag,
websiteIds: [1058, 1059]
};
$http.post("/umbraco/api/damtags/addtags", data)
.then(function (response) {
});
};
};
$scope.loadTags = function (mediaId) {
$http.get("/umbraco/api/damtags/gettags", { params: { mediaId: mediaId } })
.then(function (response) {
$scope.tags = response.data;
});
};
$scope.loadTags(111);
});
