3

Here is my plunker - http://plnkr.co/edit/uqSB1gIz6XEmJfC8zHNb?p=preview

I am trying to inject Angular Strap

The index.html is including the right dependencies and in correct order

<script data-require="jquery@*" data-semver="2.0.1" src="http://code.jquery.com/jquery-2.0.1.min.js"></script>
<script data-require="[email protected]" data-semver="1.1.5" src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
<script data-require="[email protected]" data-semver="2.3.2" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script data-require="[email protected]" data-semver="0.6.6" src="//cdnjs.cloudflare.com/ajax/libs/angular-strap/0.6.6/angular-strap.min.js"></script>

My console says

Error: Unknown provider: $strap.directivesProvider <- $strap.directives <- notificationDirective
@http://code.angularjs.org/1.1.5/angular.min.js:29
c@http://code.angularjs.org/1.1.5/angular.min.js:27
@http://code.angularjs.org/1.1.5/angular.min.js:30
c@http://code.angularjs.org/1.1.5/angular.min.js:27
d@http://code.angularjs.org/1.1.5/angular.min.js:27
@http://code.angularjs.org/1.1.5/angular.min.js:37
forEach@[native code]

2 Answers 2

3

The module dependency for AngularStrap is listed in the wrong place. '$strap-directives' is a module dependency, not a service dependency, so it needs to be listed during the app bootstrap like:

var app = angular.module('myApp', ['$strap.directives']);

It also needs to be removed as a service DI in your directive:

app.directive('notification', function(){
    return {
        restrict: 'E',
        replace: true,
        scope: {
            ngModel: '='
        },
        template: '<div>Test</div>'
    }
});

This is the way they configure the Plunkers on the AngularStrap site as well.

Sign up to request clarification or add additional context in comments.

Comments

1

$strap.directives is a module. You need to define it as a dependency for your own module:

var app = angular.module('myApp', ['$strap.directives']);

You need not inject this into the directive. Thus your directive will only look like:

app.directive('notification', function(){
  return {
    restrict: 'E',
    replace: true,
    scope: {
      ngModel: '='
    },
    template: '<div>Test</div>'
  }
});

1 Comment

This will throw an error because the directive tries to inject strap unsuccessfully

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.