Javascript 单击ng后,在AngularJS控制器内以JSON格式发布来自html属性数据kay的数据

Javascript 单击ng后,在AngularJS控制器内以JSON格式发布来自html属性数据kay的数据,javascript,angularjs,rest,Javascript,Angularjs,Rest,我对按钮/div中自定义数据键属性的POST数据有问题。 应用程序,加载后获取数据键属性的值。单击一个按钮后,使用此属性的POST值生成一个函数 问题是,我在制作正确的$scope时遇到了麻烦,无法从单击的按钮以JSON格式传递正确的值(应用程序有1-3个可单击的按钮,每个按钮都有不同的值) 请给予提示或建议,致以最良好的问候 控制器: var myApp = angular.module( 'crm', [] ); myApp.controller( 'AppCtrl', [ '$scope

我对按钮/div中自定义数据键属性的POST数据有问题。 应用程序,加载后获取数据键属性的值。单击一个按钮后,使用此属性的POST值生成一个函数

问题是,我在制作正确的$scope时遇到了麻烦,无法从单击的按钮以JSON格式传递正确的值(应用程序有1-3个可单击的按钮,每个按钮都有不同的值)

请给予提示或建议,致以最良好的问候

控制器:

var myApp = angular.module( 'crm', [] );

myApp.controller( 'AppCtrl', [ '$scope', '$http', function ( $scope, $http ) {
  console.log( 'Hello from controller!' );

  $http.get( '/xxx/dictionary' ).success( function (response) {
    $scope.items = response;
    console.log( 'I got data I requested: \n' + response);
    $scope.proceed();

  } );

  $scope.proceed = function () {
    var selectedOption = $scope.selectedOption;

    console.log( 'Count fn() clicked' );
    $http.get( '/xxxx/xxxx' ).success( function ( response ) {
      if (response) {
        console.log( 'You are in context, good luck! ' + '\n CI: ' + response + '\n Selected val: ' + $scope.selectedOption );
        $http.get( '/xxx/offers/' + selectedOption ).success( function ( response ) {
          $scope.offers = response;
          console.log( 'Got offers data I requested:\n' + response );
        } );
      }
      else {
        console.log( 'Please pick up a context!' );
      }
    } )
  };

  $scope.sell = function() {

    console.log( 'Sell clicked!' );
    $http.post( '/response' )...?        <--- Here is Problem
  };
var myApp=angular.module('crm',[]);
控制器('AppCtrl',['$scope','$http',函数($scope,$http){
log('Hello from controller!');
$http.get('/xxx/dictionary').success(函数(响应){
$scope.items=响应;
log('I got data I request:\n'+response);
$scope.procedure();
} );
$scope.procedure=函数(){
var selectedOption=$scope.selectedOption;
log('Count fn()clicked');
$http.get('/xxxx/xxxx').success(函数(响应){
如果(答复){
log('您在上下文中,祝您好运!'+'\n CI:'+response+'\n Selected val:'+$scope.selectedOption);
$http.get('/xxx/offers/'+selectedOption)。成功(函数(响应){
$scope.offers=响应;
log('Got offers data I request:\n'+response);
} );
}
否则{
log('请选择上下文!');
}
} )
};
$scope.sell=function(){
log('Sell clicked!');
$http.post('/response')…?我在控制器中创建了
函数(offer,id)
,在视图中,我创建了
sell(offer,$event)
,并在控制器中使用以下参数获取值:

var action = id.target.attributes.data.value;
感谢您的提示,特别是提示
sell(offer)

尊敬!

我在控制器中创建了
功能(offer,id)
,在视图中,我创建了
销售(offer,$event)
,我在控制器中通过以下方式获取价值:

var action = id.target.attributes.data.value;
感谢您的提示,特别是提示
sell(offer)


尊敬!

$scope.sell的签名更改为
功能(优惠)
并在单击中传递优惠,例如
ng click=“销售(优惠)”
。然后您可以发布特定的
报价
。正如@Claies所说。另外,如果您在视图中不使用$scope,请不要将其放入$scope中。success is deprecated函数(报价)可以并且运行良好,thnak you=).现在我有了$http对象req,就像在文档中一样。但是你能告诉我如何从Parameterr数据键中加入额外的值吗?(我已经将值从{{offer.statusId}}更改为字符串中的另一个数据)例如,我的对象看起来像:var req={method:'POST',url:'/xxxx/response',头:{'Content Type':'application/json'},数据:{“offerId”:0,“offerStatusId”:offer.statusId,“responseCode”:“ZAPL”};我不想将其加入到数据的末尾。将
$scope.sell
的签名更改为
函数(offer)
并在单击中传递报价,例如
ng click=“sell(offer)“
。然后您可以发布特定的
offer
。正如@Claies所说。另外,如果您在视图中不使用$scope,请不要将其放入$scope中。success is disprecated函数(offer)可以并且运行良好,thnak you=).现在我有了$http对象req,就像在文档中一样。但是你能告诉我如何从Parameterr数据键中加入额外的值吗?(我已经将值从{{offer.statusId}}更改为字符串中的另一个数据)例如,我的对象看起来像:var req={method:'POST',url:'/xxxx/response',头:{'Content-Type':'application/json'},数据:{“offerId”:0,“offerStatusId”:offer.statusId,“responseCode”:“ZAPL”};我不想将其加入到数据的末尾。