вы можете добавить ng-model="selectedUser"
к своему выбору и в свой userCtrl
<!-- template.html -->
<select id="entityDropDown" ng-options="user as user.name for user in users" ng-model="selectedUser">
</select>
<div class="user-info" ng-show="selectedUser">
<p> {{selectedUser.name}}</p>
<!-- ... -->
</div>
в вашем контроллере
// controller.js
function userCtrl($scope, siteCollection){
$scope.users = siteCollection.getUsers();
$scope.$watch('selectedUser', function(oldVal, newVal) {
if (oldVal === newVal) return;
//do something like call JSON if need it
});
}
Когда <select>
изменяет $scope.selectedUser
] изменяется на выбранное значение. позже вы можете использовать переменную selectedUser
как держатель для вашего отображения информации в другое место, например, в div.user-info
, или вы можете использовать $scope.$watch('selectedUser'...
для запуска других действий, таких как вызов служб или что-то еще
, используя ваш шаблон
<select id="entityDropDown" ng-options="user in users" ng-model="selectedUser">
<!-- <option ng-repeat="user in users">{{user.name}}</option> -->
</select>
<div>
<label for="entityId">ID: </label>
<input type="text" id="entityId" disabled ng-model="selectedUser.id"/>
</br>
<label for="entityDomain">Domain: </label>
<input type="text" id="entityDomain" disabled ng-model="selectedUser.domain"/>
</div>
Попробуйте следующее:
import numpy as np
import matplotlib.pyplot as plt
x = open(r'''C:\Users\Documents\ex.txt''')
ls = x.readlines()
x1 = np.array([])
x2 = np.array([])
x_array = np.array([])
x3_array = np.array([])
for l in ls:
col = l.split()
x_array = np.append(x_array, [float(col[0]), float(col[1])])
x1 = np.append(x1,float(col[0]))
x2 = np.append(x2,float(col[1]))
x3_array = np.append(x3_array, np.polyfit(x1,x2,1))
sub_res = x_array - x3_array
print (sub_res)