Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:02:51+00:00 2026-06-15T03:02:51+00:00

Can anyone correct what Im doing here Uncaught TypeError: Object function DataService($scope) { this.$scope

  • 0

Can anyone correct what Im doing here

Uncaught TypeError: Object function DataService($scope) {
        this.$scope = $scope;

        // Members Area
        var addVessel = function (userId) {
            alert("user"+userId);
        };

    } has no method 'addVessel'

Many Thanks – Im new to this

After reviewing the responses it seems the problem is nested higher up

This is the namespace/class

// Member Service Namespace
var MemberService;
(function (MemberService) {

// Member service type
var DataService = (function ($scope) {

    // Construct the data service
    function DataService($scope) {
        this.$scope = $scope;

        // Members Area
        this.addVessel = function (userId) {
            alert("user"+userId);
        };

    }

    return DataService;
})();
MemberService.DataService = DataService;

})(MemberService || (MemberService = {}));

and this is the call

MemberService.DataService.addVessel('XXX');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:02:52+00:00Added an answer on June 15, 2026 at 3:02 am

    You never add the method addVessel() to the object, but use it just as a “private” method within the object’s scope.

    Use this instead:

    function DataService($scope) {
        this.$scope = $scope;
    
        // Members Area
        this.addVessel = function (userId) {
            alert("user"+userId);
        };
    
    }
    

    EDIT

    Your error seems to be, that you create a constructor function with DataService, but never actually call this constructor.

    So one solution would be to change this line

    MemberService.DataService = DataService;
    

    into

    MemberService.DataService = new DataService( param );
    

    This will create a new instance of your `DataService and attach this to MemberService.DataService.

    If you, however, want to create multiple instances, your code would be right so far, but in order to call, you first have to create an object of this constructor:

    var myService = new MemberService.DataService( param );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me why this code would not be working? $('body').on('test', function() {
Can anyone tell me what the correct Plinq code is for this? I'm adding
Can anyone correct the expression below to also not allow blank field? <asp:RegularExpressionValidator ID=expEmail
Can anyone explain to me why this program: for(float i = -1; i <
Can anyone help - this is driving me mad. I am calling a mysql
Can anyone explain why here a = [] ? 1 : 2 a will
I know I'm doing something wrong here: document.getElementById(body_bg_top).style.background-image:url(main_bg_top.jpg); If anyone can correct me I
Can anyone summarize what is the correct usage of realloc() ? What do you
Can anyone enlighten me, what is the difference between hasOwnProperty and propertyIsEnumerable : function
Can anyone let me know how can we change the value of kendo combobox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.