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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:32:55+00:00 2026-06-12T00:32:55+00:00

Warning: Angular newbie ahead. I have this code in an angular.js page <div class=clearfix

  • 0

Warning: Angular newbie ahead.

I have this code in an angular.js page

  <div class="clearfix" ng-controller="Controller">

    <h1>Active Ideas 
    <button type="button" ng-click="search()">get Ideas</button></h1>
    <hr>

and then I have defined my controller as:

function Controller($scope, $http) {
  $scope.search = function(){...

And it works fine.

I’d like to execute search() function when the dom is ready…

I tried calling it from a $(function() {… but I don’t know how to manually execute a method from my controller

Also tried with

$scope.$on('$viewContentLoaded', function() {

But couldn’t make it work (and couldn’t find much documentation either…)

  • 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-12T00:32:56+00:00Added an answer on June 12, 2026 at 12:32 am

    You should execute search when your Controller is initialized. i.e.

    function Controller($scope, $http) {
      $scope.search = function(){...};
      $scope.search();
    }
    

    When Angular’s Dependency Injection constructs your controller then you know that the your view is compiled, linked, and ready for initialization code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Warning - asp newbie) I have an aspx file with the tag <%@ Page
Warning: This is inherited legacy code that was initially put together in the early
WARNING: This is an exploit. Do not execute this code. //shellcode.c char shellcode[] =
WARNING: Complete newbie to RoR and Ruby alert! * I have a login method
Warning: git novice here. I have downloaded the source code of an open-source project
WARNING: THIS CODE SUCKS, SEE ANTHONY'S COMMENTS Which is faster? 1. public bool IsValueType<T>(T
WARNING: content not work-appropriate This does not retrieve image successfully from a web page
Warning. This is a total newbie question for Groovy.. I'm from a Java background
Warning: Note that this is a dumb question of something that I would probably
(Warning: Clueless Rails Newbie!) In my show.html.erb for my albums view, I call a

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.