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 8968393
In Process

The Archive Base Latest Questions

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

Say you have a form that has values loaded from database. How do you

  • 0

Say you have a form that has values loaded from database. How do you initialize ng-model?

Example:

<input name="card[description]" ng-model="card.description" value="Visa-4242">

In my controller, $scope.card is undefined initially. Is there a way besides doing something like this?

$scope.card = {
  description: $('myinput').val()
}
  • 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-15T17:26:52+00:00Added an answer on June 15, 2026 at 5:26 pm

    This is a common mistake in new Angular applications. You don’t want to write your values into your HTML on the server if you can avoid it. If fact, if you can get away from having your server render HTML entirely, all the better.

    Ideally, you want to send out your Angular HTML templates, then pull down your values via $http in JSON and put them in your scope.

    So if at all possible, do this:

    app.controller('MyController', function($scope, $http) {
        $http.get('/getCardInfo.php', function(data) {
           $scope.card = data;
        });
    });
    
    <input type="text" ng-model="card.description" />
    

    If you absolutely MUST render your values into your HTML from your server, you could put them in a global variable and access them with $window:

    In the header of your page you’d write out:

    <head>
       <script>
           window.card = { description: 'foo' };
       </script>
    </head>
    

    And then in your controller you’d get it like so:

    app.controller('MyController', function($scope, $window) {
       $scope.card = $window.card;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that gets values from a database created by a model.
Lets say that you have a following simple application: <form action=helloServlet method=post> Give name:<input
Say I have a form that contains a drop-down list populated by values stored
Let's say I have a form that collects a first name and a last
Let us say that I have a form to search by multiple tags in
Let's say I have a form where users can search for people whose name
Say I have a base form of a word and a tag from the
Using C#, say you have a ComboBox that has a DropDownStyle set to DropDown
I have an object that has a dynamic number of attributes. For example a
I have a form that has several fields that are optional. When the mysql

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.