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

  • SEARCH
  • Home
  • 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 8857173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:31:41+00:00 2026-06-14T14:31:41+00:00

Reading knockoutJs tutorial and couldn’t make this to work. On the first page, the

  • 0

Reading knockoutJs tutorial and couldn’t make this to work. On the first page, the first approach was used and on the second page the second approach was used to create a model. But the second approach was not working. What could be the problem?

First Approach

var AppViewModel {
    this.firstName = 'Bob',
    this.lastName = 'Smith'
};

Second Approach

function AppViewModel() {
    this.firstName = 'Bob';
    this.lastName = 'Smith';
}

Html portion is below:

<body>

  <span data-bind="text: firstName"></span>



  <script type="text/javascript">
      ko.applyBindings(AppViewModel);
  </script>
</body>

This works for the first approach but the second approach throws error:

Uncaught Error: Unable to parse bindings. Message: ReferenceError:
firstName is not defined; Bindings value: text: firstName

  • 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-14T14:31:42+00:00Added an answer on June 14, 2026 at 2:31 pm

    In the first approach you defined an object. In the second approach you defined a class’ constructor so you have to create an instance of the class using new keyword:

    <body>
      <span data-bind="text: firstName"></span>
    
      <script type="text/javascript">
          ko.applyBindings(new AppViewModel());
      </script>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

reading this https://developers.google.com/in-app-payments/docs/tutorial Quoted from the above page: Because you sign the JWT using
Reading this article I thougth automatic property work on .NET Framework 3.0, but some
I am reading this very interesting article about knockoutJs ( http://wildermuth.com/2011/11/20/Using_MVVM_on_the_Web_with_KnockoutJS ) And I
Reading the MCIMX50 Application Processor Reference Manuals on page 1368 (Section 33.3) there is
Reading the Scala by Example book and there is this example when Martin explains
Reading through this excellent article about safe construction techniques by Brain Goetz, I got
Reading an MSDN tutorial on Extending Hosting Using ServiceHostFactory , there is an example
Reading the documentation I thought this code would write logs to a file in
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
Reading Real World Haskell, on page 95 the author provides an example: myFoldl f

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.