【发布时间】:2015-12-14 18:18:11
【问题描述】:
我现在在 angularjs 和 coffeescript 中做一些任务。我有这样的要求:我的 html 页面中有几个按钮,例如:
<div>
<button type="button" class="btn btn-default" ng-click="button1();">Button1</button>
<button type="button" class="btn btn-default" ng-click="button2();">Button2</button>
</div>
如果我点击 Button1,那么它应该重定向到另一个页面(比如:'/test1.html'),同样,如果我点击 Button2,那么它应该重定向到另一个页面(比如:'/test2.html ')。 如何在 AngularJS/CoffeeScript 中做到这一点?
如果我在我的咖啡脚本文件中这样做,我会收到以下错误:
app = angular.module('myApp', dependencies)
app.controller 'WizardController', [
'$scope',
($scope) ->
$scope.button1 = ->
window.location = '/test1.html'
return
$scope.button2 = ->
window.location = '/test2.html'
return
]
但它在返回语句处给出编译错误:编译错误:第 103 行的解析错误:意外的 'TERMINATOR'
【问题讨论】:
标签: javascript html angularjs coffeescript