で認識されていない私は、角度+ CoffeeScriptのにかなり新しいですとRailsプロジェクトのためにそれを使用しています。私はビュー内のボタンを押すと実行されるコントローラ内に関数を作成しようとしています。 角度コントローラ機能は、CoffeeScriptの
この
これはコントローラangular.module("deloitte").controller('labsCtrl', ['$scope', 'labService','labPreferencesService', ($scope, labService, labPreferencesService) ->
labService.query (data) ->
$scope.clients = data
# console.print (clients)
$scope.test -> console.log("Hello!");
])
されるHTML
<div id="labs">
<div class="clients" ng-repeat="client in clients" ng-class="{first: $index == 0}">
<h1>{{client.name}}</h1>
<div class="labs">
<ul>
<li ng-repeat="lab in client.labs">
<a ng-href="/#!/labs/{{lab.id}}/process">
<button ng-click = "test()">Test</button>
<span>{{lab.name}}</span>
<span>{{lab.created_at | date:'MMMM yyyy' }}</span>
</a>
</li>
</ul>
</div>
</div>
</div>
であり、これは、私は、構文を見上げエラー
angular.js?body=1:5755 TypeError: $scope.test is not a function
at new <anonymous> (labsController.js?body=1:7)
at invoke (angular.js?body=1:2903)
at Object.instantiate (angular.js?body=1:2915)
at angular.js?body=1:4806
at update (angular.js?body=1:14199)
at Object.Scope.$broadcast (angular.js?body=1:8308)
at angular.js?body=1:7464
at wrappedCallback (angular.js?body=1:6847)
at wrappedCallback (angular.js?body=1:6847)
at angular.js?body=1:6884
であり、それが正しいようです。 Doing = - >もエラーをスローします。ヘルプ
あなたのインデントが正しくありません。 CSのランダムなインデントは問題を引き起こします。 –
はまた、それは、あなたが* *それはテストするために割り当てる必要が書かれたとしても意味がありません。あなたはコントローラに 'test'関数を渡していません。 –