Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clearSearch): Allow users to clear search field by using $rootScope.$broadcast #61

Merged
merged 1 commit into from Oct 13, 2014
Merged

Conversation

ghost
Copy link

@ghost ghost commented Oct 10, 2014

From Controller call $rootScope.$broadcast('angucomplete-alt:clearSearch');

@ghiden ghiden merged commit 36abc21 into ghiden:master Oct 13, 2014
@jlhffmn
Copy link

jlhffmn commented Dec 31, 2014

I get this error: $rootScope is not defined
It is not clear from the Angular documentation how to declare $rootScope. I have only one controller in my angular.module. I tried using $scope, but this did not work.

Could you point me to some sample code?

@ghost
Copy link
Author

ghost commented Jan 1, 2015

When you use $rootScope you will have to inject it into your controller the same way you inject $scope:

angular.module('myApp')
  .controller('myCtrl', ['$scope', '$rootScope',... .

Just the dependency injection angular uses.

@jlhffmn
Copy link

jlhffmn commented Jan 2, 2015

Thanks. That worked.

***** Note that in the latest code, the broadcast event is now named 'angucomplete-alt:clearInput' *****

I was not clear on syntax of the controller constructor parameters. For others who may need the exact syntax:
myApp.controller("myController", ['$scope', '$rootScope', '$http', function($scope, $rootScope, $http) {
...
}]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants