AngularJS未定义范围变量

时间:2015-05-07 12:19:07

标签: javascript ruby-on-rails angularjs coffeescript slim-lang

我的问题是,每次选择标记更改时,ProductContooller.js.coffee中的值$ scope.variationValue都是未定义的。知道为什么它的undefine?

ProductContoller.js.coffee

controllers = angular.module('controllers')
controllers.controller("ProductController", [ '$scope', '$routeParams', '$location','Restangular'
  ($scope,$routeParams,$location,Restangular)->

    $scope.update_variation = ()->
      console.log $scope.variationValue <---- undefined why?

    Restangular.one('products', $routeParams.id).get().then (c) ->
      $scope.price = c.cheapest_variant.price
      $scope.product = c
      return
])

product.html.slim

.form-group
  label for="sel1"  Variations:
  select ng-options="variant as variant.opt1_value for variant in product.variants" ng-model="variationValue" ng-change="update_variation()"
  | Value {{variationValue.price}}

0 个答案:

没有答案