[SOLVED] Call service function in view


#1

I create a “Common” service (factory) in AngularJS like this:

angular.module('myApp')
	.factory('Common', function($state) {
            ...

In my controller, I bind my service with my view like this:

angular.module('myApp')
	.controller('myCtrl', function($scope, Common) {
		$scope.C = Common;
                ...

But in my view, I can’t access to the methods of my service … why?
Like this:

<element ng-click="C.foo()" />

I used this trick in several AngularJS projects so I know it should work.


#2

Do you have a sample in codepen where it is not working?