Note that there are some explanatory texts on larger screens.

plurals
  1. POincluding fetched data in DOM element via angularjs
    primarykey
    data
    text
    <p>So i am trying to convert my app from jQuery to angularjs.</p> <p>I want to create a dynamically shown box which shows data fetched from a mySQl database, based on user input.</p> <p>My PHP script returns a JSON.</p> <p>I set up my <code>&lt;div&gt;</code> and an <code>&lt;input&gt;</code> field:</p> <pre><code>&lt;input type="text" ng-model="testActivator"&gt; &lt;div class="Container" ng-show="Activator.length" ng-controller="ContainerCtrl"&gt; &lt;p&gt;{{fetchData(testActivator)}}&lt;/p&gt; &lt;/div&gt; </code></pre> <p>And i create my controller:</p> <pre><code>function ContainerCtrl($scope,$http){ $scope.item = [{}]; $scope.fetchData = function($input){ $http.post("../sys/core/fetchPacking.php",{ 'val': $input }).success(function(data,status){ $scope.item.push(data.key); }); return $scope.item; } $scope.hide = function(){ return false; } } </code></pre> <p>Now, the following and questions came up:</p> <ul> <li>When i start the script by giving input to the <code>&lt;input&gt;</code>, it will produce something that looks like an infinite loop to me: the returned data will be passed in the box over and over again. How do i prevent this and why is it?</li> <li>Instead of the correct value, the script returns <code>null</code>. Where is my fault?</li> </ul> <p>p.s. issue #1 throws also up another question: How do i watch my returned values. Until today, i would have parsed it to the console via <code>console.log()</code>. But as this runs in a loop, that won't work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload