0

I can't get this simple Angular example to work.

I'm getting Uncaught Error: [$injector:modulerr] Failed to instantiate module app

HTML:

   <div ng-app="app" ng-controller="Example"> 
      <input type="text" placeholder="#1 Main Odd" 
              ui-blur="testfn('data.mainOdd1', $event, '#1 Main Odd');">
    </div>

Javascript:

angular
  .module('app', [])
  .directive('uiBlur', function($parse) {
    return function(scope, elem, attrs) {
      elem.bind('blur', function(event) {
        scope.$apply(function() {
          $parse(attrs.uiBlur)(scope, {
            $event: event
          });
        });
      });
    };
  })
  .controller('Example', function($scope) {
    $scope.testfn = function(propertyName, $event, placeHolder) {
      debugger;    
      console.log(propertyName, $event);
    };
  });

What am I doing wrong here?

Thanks

0

1 Answer 1

1

Click on Javascript button in fiddle and select the Load Type to No wrap in <head> or No wrap in <body> option.

And Boom! Error is gone :)

Refer this fiddle : https://jsfiddle.net/varit05/mhnLL6ro/

Cheers!

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

1 Comment

2 seconds later :) great catch

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.