я работаю над Activiti и нужно, чтобы скрыть эту кнопку:Angularjs - Скрыть элемент, если элемент оленья кожа существовать
, если ни один процесс не Instantiate, т.е. если сервер возвращения этого (кнопка шоу):
вместо этого (в данном случае кнопка скрыть):
Это код для кнопки я использовал в HTML:
<div ng-controller=getDeploy>
<h3>Deployments Info</h3>
<br>
<table class="table" table-bordered table-hover>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Deployment</th>
<th>Category</th>
<th class="text-center">Url</th>
</tr>
</thead>
<tbody>
<tr class="info" ng-repeat="x in names">
<td class="danger">{{ x.id }}</td>
<td>{{ x.name }}</td>
<td class="warning">{{ x.deploymentTime }}</td>
<td>{{ x.category }}</td>
<td>{{ x.url }}</td>
</tr>
</tbody>
</table>
</div>
<div style="width:200px; float:left;" ng-controller="InstanziateProcess">
<button ng-click="processdef()">
Instanzia il Processo
</button>
</div>
и JS:
function InstanziateProcess($scope, $http, Base64) {
$http.defaults.headers.common['Authorization'] = 'Basic ' + Base64.encode('kermit' + ':' + 'kermit');
$http.get("http://localhost:8080/activiti-rest/service/repository/process-definitions")
.then(function (response, data, status, headers, config) {
var key = response.data.data[0].key;
var req = {
method: 'POST',
url: "http://localhost:8080/activiti-rest/service/runtime/process-instances",
data: {
processDefinitionKey: key
},
headers: {
'Authorization': 'Basic ' + Base64.encode('kermit' + ':' + 'kermit'),
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
$scope.processdef = function() {
$http(req).then(function (response, data, status, headers, config) {
console.log(response);
});
};
});};
error: TypeError: Невозможно прочитать свойство 'length' undefined – Luke
Это может быть response.data.length not response.data.data. длина. Зависит от того, какой ответ содержит. –
Я решил, я использовал data.total! = 0, и он работает :) Спасибо вам все равно за Idea: D – Luke