我正在尝试在控制器中设置一个变量,而另一个值是通过def method_3():
mat = gen_fake_data()
x = np.unique(mat[:,0])
y = np.unique(mat[:,1])
X,Y = np.meshgrid(x, y)
# I'm fairly sure there's a more efficient way of doing this...
def get_z(mat, x, y):
ind = (mat[:,(0,1)] == (x,y)).all(axis=1)
row = mat[ind,:]
return row[0,2]
z = np.array([get_z(mat,x,y) for (x,y) in zip(np.ravel(X), np.ravel(Y))])
Z = z.reshape(X.shape)
plt.pcolormesh(X,Y,Z)
plt.xlim(min(x), max(x))
plt.ylim(min(y), max(y))
plt.show()
选择的。例如,如果根据ng-options
从Companies
中选择一个,那么title
将被设置为特定公司的相应myValue
。以下是HTML代码段:
id
我的<select multiple="" class="form-control" ng-model="myValue"
ng-options="d.title for d in Companies"></select>
<select multiple="" class="form-control">
<option ng-placeholder="{{myValue}}"></option>
</select>
,Company
和Companies
在控制器中:
myValue
以下是function Company(title, last, pw, id) {
this.title = title;
this.id = id;
}
$scope.Companies = [];
$scope.myValue = '';
数组的种子:
Companies
该程序背后的目的是根据所选的$scope.getValues = function () {
$http.get('/route/to/names')
.success(function (data, status, headers, config) {
for (var i = 0; i < data.length; i++) {
$scope.Companies.push(new Company(data[i]['Title'],data[i]['ID']));
}
})
};
进一步从数据库中获取数据。我在页面上设置Company
作为选项的原因是确定是否实现了操作。任何关于如何解决这个或类似问题的建议将不胜感激!谢谢!
答案 0 :(得分:0)
d.id as d.title for d in Companies