-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating Angular Controller from Fay Module: API brainstorm #3
Comments
I think this is a dead end; no sense in trying to treat modules as first class just yet. |
I think we can reopen this, even if the module approach isn't appropriate people may have ideas on how to do it better. I don't know much about angular controllers, so I'm just brainstorming a bit too. I think you can accomplish the same task by using records, You probably also want some generic notion of Controller, which you can do like this:
Note that This depends a bit on how angular controllers work, can they define arbitrary methods? Are some required? |
Controllers can define arbitrary methods, but by default the variable name "$scope" is magic. I think we can do something involving making an angular "Provider"; at least, if I take a simple controller and change instances of
|
I only arrived at attaching my methods to $scope by trial and error, and perhaps it's not the best solution. Here's the mental model I've developed so far: in the html template, declare "reactive values" and the relations between them. In Fay, declare the auxiliary data and functions used in the relations. In javascript, wire up the template to the code. I had this:
and that did not work. But by adding someFunction to $scope, and changing the equation to |
Hello all. I'm a newbie to Haskell, but I am a core contributor to AngularJS and was hoping to offer that expertise to this discussion. AngularJS 1.2 introduces a someModule.controller('MyCtrl', function ($scope) {
$scope.myMethod = function () { /* ... */ };
}); <div ng-controller="MyCtrl">
<a href ng-click="myMethod()">do it</a>
</div> You can now do: function MyCtrl () { /* ... */ }
MyCtrl.prototype.myMethod = function () { /* ... */ };
someModule.controller('MyCtrl', MyCtrl); <div ng-controller="MyCtrl as ctrl">
<a href ng-click="ctrl.myMethod()">do it</a>
</div> The new |
Here's what I'm using to generically build a controller out of a Fay module.
Assuming this is even a good starting point, is there a way to package up that code into Fay action? Say, for instance,
and then:
The text was updated successfully, but these errors were encountered: