3gwebtrain
3gwebtrain

Reputation: 15303

Parse not working, throwing error on complie

I am doing a simple testing using angularjs parse method. I am not come with correct output from the testing what i do.

here is my code for angular:

var parseApp = angular.module('parse',[]);
parseApp.controller('parseController', ['$scope','$parse', function($scope,$parse){
    $scope.parsedValue = "Testing";
    $scope.$watch('expr',function(newVal,oldVal,scope){
        if(newVal !== oldVal){
            var parseFun = $parse(newVal);
            $scope.parsedValue = parseFun(scope);
        }
    });
}])

the html is like this:

<div ng-app="parse">
    <div ng-controller="parseController">
        <input ng-model="expr"type="text" placeholder="Enter an expression" />
        <h2>{{ parsedValue }}</h2>
    </div>
</div>

getting error as:

Uncaught Error: [$injector:modulerr] Failed to instantiate module parse due to:
Error: [$injector:nomod] Module 'parse' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify th...<omitted>...0) 

any one please figure-out me the wrong what i do here please?

Live Demo

Upvotes: 0

Views: 212

Answers (1)

V31
V31

Reputation: 7666

parse is a reserved word in Angular as it has a service with this name $parse, You need to have a different name, I had parse1 in your fiddler and it worked

Working Fiddle

Code:

var parseApp = angular.module('parse1',[]);

Upvotes: 1

Related Questions