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

Unable to use Kalei to document simple AngularJS examples #45

Closed
webmaven opened this issue Feb 27, 2014 · 4 comments
Closed

Unable to use Kalei to document simple AngularJS examples #45

webmaven opened this issue Feb 27, 2014 · 4 comments

Comments

@webmaven
Copy link

I would like to use Kalei to document various Angular directives that render UI widgets in use throughout my app. Unfortunately, it doesn't look like I can get even the simplest Angular examples to work. 😢

I added ng-app to the html tag in index.html, as well as adding the following to the bottom of the body: <script src="../js/angular.min.js">, but the following example in a css file still does not work:

/*
## Widgets

```
<input type="text" ng-model="name" /> {{ name }}
```
*/

The {{ name }} remains displayed literally.

Any clues on getting a basic AngularJS example working within Kalei?

@webmaven
Copy link
Author

So, I figured out that I was adding ng-app to the wrong spot, and added it to all the <html> elements in the head. The result isn't pretty, and it actually messes up the navigation somehow (the top level navigation items expand vertically quite a bit), but the example code still doesn't get processed.

I turned to a different approach, removing all the ng-app markup and replacing it with a script tag just below the one that adds Angular:

<script type="text/javascript">
   angular.element(document).ready(function() {
     angular.module('myApp', []);
     angular.bootstrap(document, ['myApp']);
   });
</script>

However, although the navigation is no longer screwed up, the Angular example remains unchanged. I'll keep poking at the problem.

@webmaven
Copy link
Author

Suggested a possible solution in #46.

@webmaven
Copy link
Author

webmaven commented Mar 3, 2014

OK, I have made some more progress, although my solution so far is rather ugly.

Instead of using ng-app or the script above, I made the following changes:

  1. Added angular as a dependency to the require in js/main.js
  2. Added the following to js/views/style/page.js just before fixie.init():
// Angularize Page
var app = angular.module('myApp', []);
angular.bootstrap(document, ['myApp']);
console.log('After Angular bootstrapping');

And voila, my simple <input type="text" ng-model="name" /> {{ name }} example above works.

However, modifying Kalei itself in this way strikes me as ugly, so I was hoping there is a cleaner way to accomplish the same thing. Any suggestions or guidance?

@webmaven
Copy link
Author

Closing.

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

1 participant