title: automatically click button after page load in angularjs
body: <p>I am looking to know if there is a way to perform a button click automatically on an angularjs page once the page loads based on a querystring value. For example in a simple asp.net web forms page if a querystring in a url is true then I can simply call <code>Button1_Click(sender,e);</code> to handle the click event in the page load. But this HTML5 page uses angularjs and I just cant seem to figure out how to do it. Any help would be highly appreciated.</p>
  
  <p>EDIT: Maybe I wasnt clear enough in my explanation...my bad. But here goes..This is what I intend to do.[Since I cant post pictures yet...]</p>
  
  <pre>http://host/app/Quik.aspx?Order=5779809</pre>
  
  <p>UI:</p>
  
  <pre><code>TxtLookupNum: {{InputValue}}    DdlWMS:{{WMSKey}}    DdlWsNum: {{WorkStationName}}
  btnLookup:Submit
  </code></pre>
  
  <p>Angular code:</p>
  
  <pre><code>$scope.Lookup = function(WMSKey,InputValue,WSNum);
  </code></pre>
  
  <p>When my aspx page has a query string parameter I'd like to automatically trigger a click event and pass the 3 parameters to my angular method like above. </p>
  
  <p>This is how I wrote it and it worked but:</p>
  
  <pre><code>var inputVal = $('#txtLookupNum'); 
  if (inputVal.val() != "") {$("#btnLookup").trigger("click");}   
  </code></pre>
  
  <p>But now I am getting the below error:</p>
  
  <blockquote>
    <p>TypeError: <strong>Cannot read property '0' of undefined</strong> [after stripping out all the stack trace]</p>
  </blockquote>