Jure Polutnik
Jure Polutnik

Reputation: 587

AngularUI integration - accessing module value from script

I have successfully integrated AngularUI into AngularJS application following instructions on stackoverflow (How to integrate AngularUI to AngularJS?).

Now I am trying 'jQuery Passthrough' example from official AngularUI page.(http://angular-ui.github.io/).

<a title="Easiest. Binding. Ever!" ui-jq="tooltip">Hover over me for static Tooltip</a>

<a data-original-title="{{tooltip}}" ui-jq="tooltip">Fill the input for a dynamic Tooltip:</a>
<input type="text" ng-model="tooltip" placeholder="Tooltip Content">

<script>
    myModule.value('ui.config', {
    // The ui-jq directive namespace
    jq: {
       // The Tooltip namespace
       tooltip: {
           // Tooltip options. This object will be used as the defaults
           placement: 'right'
           }
       }
    });
</script>

The problem I am having is that 'myModule' variable (or whatever I try here) is not defined. Without the script, the page is working (at least the static tooltip), so I guess AngularUI is correctly configured.

What should I do to access module variable? Must this script be included into the controller class?

Thank you.

Upvotes: 0

Views: 664

Answers (1)

ProLoser
ProLoser

Reputation: 4616

You're jumping ahead before you cover some basics. In order to code your application you need to declare a module.

Normally this is done by doing something like:

var myModule = angular.module('myApp', ['ui']);

and then myApp becomes the contents of the ng-app attribute.

Alternatively, you can do:

angular.module('myApp').value('ui.config', { ...

if you do not wish to store a reference to the module in a variable. Keep in mind that storing the reference to a variable is the same as if you were to chain these calls on top of one another:

angular.module('myApp', ['ui']).value('ui.config', { ...

Any of these solutions should work for you

Upvotes: 2

Related Questions