引用控制器属性,控制器作为语法
reference controller property with controller as syntax
如何将我的devices
属性设置为从/store.aspx/GetDevices
返回的数据。使用this.devices
不起作用。
var app = angular.module("storeApp", []);
app.controller("storeController", ['$http', function ($http) {
this.devices = hardcodeddevices;
$http.post("/store.aspx/GetDevices", {})
.success(function (data) {
//this.devices = JSON.parse(data.d);
});
}]);
var hardcodeddevices = [...
在成功回调函数中,this
表示成功回调函数。您可以将this
分配给变量,例如 self
。
var app = angular.module("storeApp", []);
app.controller("storeController", ['$http', function ($http) {
var self = this;
self.devices = hardcodeddevices;
$http.post("/store.aspx/GetDevices", {})
.success(function (data) {
self.devices = JSON.parse(data.d);
});
}]);
var hardcodeddevices = [...
相关文章:
- 当使用控制器作为语法时,如何从父指令继承属性
- Angular JS“;控制器为“;语法不起作用
- "控制器作为“;$timeout中的语法
- 使用ES6类语法在控制器中分配依赖项
- AngularJS:使用$scope$以控制器作为语法进行观察
- Angular UI Grid Edit可以与“;控制器为“;语法
- 使用控制器作为语法和 ngRoute 分别加载控制器
- Angular js指令使用控制器作为语法ng点击不起作用
- 作为语法的控制器没有将新的obj传递给数组
- 控制器作为搜索输入表单的语法
- '控制器为'语法或服务
- 尝试理解$.inArray,或将$scope转换为“$scope”;控制器As”;AngularJS中的语法
- 我正在努力理解AngularJS's控制器的语法
- 以控制器为语法的多个angularjs指令实例
- 使用不带$scope的$watch(作为语法的控制器)
- AngularJS“控制器作为”语法错误
- AngularJS控制器语法 - 数组和函数版本之间的差异
- Angular JS:控制器语法
- AngularJS指令控制器语法&范围
- 如何使用"控制器"语法