drq9991 2016-07-07 18:02
浏览 140
已采纳

Javascript函数在新的innerHTML中不起作用

I am new to angular js and i am working on monaca ide to make a hybrid app which uses onsen-ui and i wrote the following code and when the response comes from the server it isn't using the javascript methods for eg the {{"hello"}} at the last line is shown in the browser as {{"hello"}} only and because of that i think that the new code doesn't follow the rules of javascript files

                  this.find=function(){
    //ajax start
    
            $http({
    method :"POST",
    url : "http://www.ashishmalgawa.xyz/rakt/finder.php",
   headers: {
   'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8"
 },    
   data: "date="+$rootScope.dob
  }).then(function mySucces(response) {
      document.getElementById("results").innerHTML = response.data;
      $scope.search=false;
                
    }, function myError(response) {
      $scope.hellow = response.statusText;
  });
     
    //ajax end         
                   }
 
<ons-list>
<?php
/* DBMS related code
*/
?>
 <ons-list-item ng-click="" modifier="tappable">
      <?php
            while($r=$re->fetch_assoc()){
                echo $r['name']."<br>";
                echo $r['gender']."<br>";
                echo "$distance kms away";
                
            }
         ?>
    </ons-list-item>
    <?php
    }
     }
}
else{
    echo "No Results Found";
}
$conn->close();         

?>
    </ons-list>
{{"hello"}}

Thanks in advance :)

</div>
  • 写回答

1条回答 默认 最新

  • dplm47571 2016-07-07 18:13
    关注

    No, this will not work, because <ons-list> etc, is not plain html, its an Angular component.

    You should return a JSON of data, and then render it on the client side the angular way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘