Skip to content
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

multiple ng-apps #63

Closed
RBleyenberg opened this issue Jun 12, 2015 · 8 comments
Closed

multiple ng-apps #63

RBleyenberg opened this issue Jun 12, 2015 · 8 comments

Comments

@RBleyenberg
Copy link

First of all thx for making this great library,

For me question, i'm looking at making an app with play and angulate lib and it's running smoothly.But the app requires multiple ng-apps running, after some searching if found this anwser http://stackoverflow.com/questions/18571301/angularjs-multiple-ng-app-within-a-page

But i'm abit lost on how to implement this with angulate where the createModule doesn't work multiple times...

Hopefully you can shine a light on this question.

@jokade
Copy link
Owner

jokade commented Jun 12, 2015

But i'm abit lost on how to implement this with angulate where the createModule doesn't work multiple times...

What happens when you call angular.createModule() more than once? Could you give a code example?

@RBleyenberg
Copy link
Author

Yup i can do that,

first i did little test in plain js like so,

var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.name = 'Superhero';
}
var myApp2 = angular.module('myApp2',[]);
function MyCtrl2($scope) {
$scope.title = 'Superhero';
}

div ng-app="myApp" ng-controller="MyCtrl">
Hello, {{name}}!
/div>
div ng-app="myApp2" ng-controller="MyCtrl2">
Hello, {{title}}!
/div>

above works

Then i tranfered it to angulate like so

object TodoApp extends JSApp {
override def main(): Unit = {

val module = angular.createModule("todomvc", Nil)

module.controllerOf[TodoCtrl]("TodoCtrl")

val module2 = angular.createModule("todomvc2", Nil)

module2.controllerOf[TodoCtrl2]("TodoCtrl2")

dom.document.getElementById("scalajsShoutOut").textContent = SharedMessages.itWorks

}
}

and what happens is that on inspection of the js file in console, the todomvc2 and todoctrl2 never get "made" also no error of any sort and var module does get loaded with totdoctrl.

Hope it helps,

@jokade
Copy link
Owner

jokade commented Jun 12, 2015

Just to make sure: did you try a sbt clean?

@RBleyenberg
Copy link
Author

did the sbt clean, didn't work. But after that, i also deleted all target maps (hard clean i guess :P) and it works both module in console.

thx for the fast answers, and help. Now for the real stuff and angulate.

Best Regards,

@jokade
Copy link
Owner

jokade commented Jun 12, 2015

That's strange, sbt cleanshould suffice...
FYI: there is an issue (#52) with controllers defined in another file than the corresponding module.controllerOf[] call

@RBleyenberg
Copy link
Author

Well prehaps it as to do with the fact that i'm running a multi domain sbt file (3 domain and scalajs). i'm likely to encounter it more so will investigated deeper, and report on any answers.

@jokade
Copy link
Owner

jokade commented Jun 12, 2015

Do you mean a "multi-project" build? I'm using that as well with scala.js and it usually works quite well. Good luck!

@RBleyenberg
Copy link
Author

yes multi-project, and i guess the word "usually" is in place here :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants