Click here to Skip to main content
15,915,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Please suggest whats wrong in below code..,
its not working for me

C#
app.provider('MyProvider', function () {
          var Name = 'Default';
          this.MyProviderMethod = function (s) {
              Name = s;
          };

          function Greeter(a) {
              this.greet = function () {
                  return Name + ',' + a;
              }
          };

          this.$get = function (a) {
              return new Greeter(a);
          };
      });

      app.config(function (MyProviderProvider) {
          MyProviderProvider.MyProviderMethod('Hi');
      });

      //app.controller('ControllerforProvider', ['MyProvider', function (MyProvider) {
      //    // this.DisplayName = MyProvider.greet('anvi');

      //    this.DisplayName = "fsss";
      //}]);


      app.controller('ControllerforProvider', ['MyProvider', function (MyProvider) {
          // this.DisplayName = MyProvider.greet('anvi');

          this.DisplayName = "h";
      }]);



in controller



XML
<div ng-controller="ControllerforProvider as Contr">
             {{ Contr.DisplayName }}
         </div>
Posted
Comments
Sreekanth Mothukuru 20-Jul-15 4:51am    
Are you missing $scope ?!!

1 solution

Hello,

You have to define $scope Please refer this Article.
Angular Tutorial - Part 1: Introduction to Angular.js [^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900