是否有一种方法可以像angular js中使用$scope那样将值返回给twig ?
is there a way to return the value to twig as in angular js using $scope
function addCourse(x){
$.post("../section/pages/tableContent.php", {data: x}, function(result) {
//here
});
};
在angular中我可以这样做
$http.post("../section/pages/tableContent.php", {data: x}).success(function (result) {
$scope.students=result.records;
});
,因为我想循环生成的数组/对象
问题不是很清楚。但是看起来你想在php+twig中使用类似于angularjs的代码。
由于您使用的是ajax,一切都必须在客户端完成,但树枝是服务器端,所以它不会有帮助。但是你可以使用jquery本身。
function addCourse(x){
$.post("../section/pages/tableContent.php", {data: x},
function(result){
$.each( result, function( i, val ) {
$("#id_of_your_ul").append("<li>"+val+"</li>");
});
});
};
如果你输入更多关于你正在尝试的内容的信息。我可以提供你需要做的事情
相关文章:
- AngularJS:ng之后,重复$scope值未按预期更新
- $ionicplatform内的$scope不;不起作用
- 使用$scope方法时的ControllerAs语法
- 如何将ngrepeat下的ngmodel绑定到$scope
- 另一个if(!$scope.$$phase)$scope$apply()szenario-需要帮助才能通关
- 使用AngularJS Directive WHITOUT$scope创建一个动态html元素
- $scope变量被视为字符串AngularJs
- ng在更新$scope后重复不更新信息
- 正在获取Angular以检测$scope中的更改
- 如何惯用地手动销毁scope&在AngularJS中重新创建
- Understanding Javascript scope with "var that = this&qu
- AngularJS,angular.element($0).scope()揭示了每个控制器的函数
- Ng出口无法访问父$scope
- ng选项-用vm替换$scope
- $scope变量,ng隐藏/显示
- 强制 $scope.$watch 只开火一次
- Ionic:AngularJS变量未使用$scope更新DOM
- Angular$scope在模式窗口内不起作用
- 在将绑定应用于控制器之后,是否会发出Angular$scope事件
- 是否有一种方法可以像angular js中使用$scope那样将值返回给twig ?