ep84 ep84 - 1 month ago 7
AngularJS Question

Angularjs controller not registering for Annyang speech recognition using service

Link to plunker snippet.

Code in plunker.


I'm trying to implement annyang speech recognition with videojs on AngularJS.

I have obtained a controller and service for implementing annyang on AngularJS, but I have not found how to successfully install it for my purposes.

The service and controller can be found at: https://github.com/levithomason/angular-annyang/tree/master/js

My intent is to set a controller for the speech recognition, which will set up and launch the service.

I'm getting the error: Error: $controller:ctrlreg A controller with this name is not registered.

I know I'm doing something wrong with the AyCtrl controller, but I'm not sure what it is, and other articles, while wordy, don't exactly show me what I'm doing wrong.

Thank you for your help.

Answer Source

Your issue is that you're recreating the module 3 times.

This creates a module, note the 2nd argument is a list of dependencies:

angular.module('myApp', ['vjs.video'])

This retrieves an already created module, note only 1 argument:

angular.module('myApp')

You need to create your module ONCE, e.g. in whichever script you load first, then every time you want to register something with that module just get it with angular.module('myApp')