Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Angularjs中将数据从视图传递到控制器_Angularjs_Binding - Fatal编程技术网

在Angularjs中将数据从视图传递到控制器

在Angularjs中将数据从视图传递到控制器,angularjs,binding,Angularjs,Binding,我从控制器中的URL获取数据,但我需要动态地获取数据 d3.json("http://localhost:2016/get_stats_for?brand_name="+$scope.brand,function(data)) 我想从视图中的文本框中获取$scope.brand 我怎么能这么做 编辑2 或者,您可以使用ng change app.controller('MyController',函数($scope,MyService){ $scope.brand='D&G';//初始化值

我从控制器中的URL获取数据,但我需要动态地获取数据

d3.json("http://localhost:2016/get_stats_for?brand_name="+$scope.brand,function(data))
我想从视图中的文本框中获取$scope.brand

我怎么能这么做

编辑2 或者,您可以使用
ng change

app.controller('MyController',函数($scope,MyService){
$scope.brand='D&G';//初始化值
$scope.onBrandChange=function(){
getByBrand($scope.brand)。然后(函数(res){
var result=res.data;//这是您的JSON
});
});
});
app.service('MyService',函数($http){
this.getByBrand=函数(品牌){
变量URL=”http://localhost:2016/get_stats_forbrand_name=“+品牌;
返回$http.get(URL);
};
});

我有一个带有条件和值的url。这个值需要从view.html中的文本框中设置