2017-04-21 122 views
2

下面是我的整个angular.js索引页面,其中五分钟前是按照预期工作显示我有我的数据库中的5个单独的条目我已设置的列表中。镀铬的重启之后就不再工作,我收到以下错误:错误:$interpolate:noconcat角js网站刚刚停止工作

<!DOCTYPE html> 
<html > 
<script 
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> 
</script> 
<style> 
    .posts { 
     margin: 0 0 2em 0; 
     list-style-type: none; 
     padding: 0; 
     width: 50em; 
    } 
    .posts li { 
     position: relative; 
     left: 0; 
     background-color: #EEE; 
     margin: .5em; 
     padding: .3em 0; 
     height: 20em; 
     border-radius: 4px; 
    } 
    .posts .text { 
     position: relative; 
     top: -3px; 
    } 
</style> 
<body> 

<div ng-app="myApp" ng-controller="postsCtrl"> 
    <h1>GWAT Websites and Designs</h1> 

    <ul class="posts"> 
     <li *ng-repeat="post in names.retRows"> 
      {{post.title}}<br> 
      {{post.pBody}}<br> 
      {{post.category}}<br> 
      <iframe ng-src={{myUrl}})></iframe><br><br> 
     </li> 
     </ul> 
    </div> 

<script> 
var app = angular.module('myApp', []); 
app.controller('postsCtrl', function($scope, $http) { 
    $scope.myUrl = $sce.trustAsResourceUrl('https://www.angularjs.org'); 
    $scope.changeIt = function (changUrl) { 
     $scope.myUrl = $sce.trustAsResourceUrl('changUrl'); 
    } 
    $http.get("http://127.0.0.1:8081/process_get") 
    .then(function (response) {$scope.names = response.data;}); 
}); 

</script> 

我从控制台,我的HTTP GET仍然返回该处理不当改变了一个合适的JSON知道。任何帮助关于这个错误或一些小错误即时失踪将不胜感激。

回答

2

有一个错字error.Also,ng-src值需要围绕双引号包裹

变化<iframe ng-src={{myUrl}})></iframe><br><br>

<iframe ng-src="{{myUrl}}"></iframe><br><br>

也,注入$sce控制器

演示

var app = angular.module('myApp', []); 
 
app.controller('postsCtrl', function($scope, $http,$sce) { 
 
    $scope.myUrl = $sce.trustAsResourceUrl('https://www.angularjs.org'); 
 
    $scope.changeIt = function (changUrl) { 
 
     $scope.myUrl = $sce.trustAsResourceUrl('changUrl'); 
 
    } 
 
    $http.get("http://127.0.0.1:8081/process_get") 
 
    .then(function (response) {$scope.names = response.data;}); 
 
})
.posts { 
 
     margin: 0 0 2em 0; 
 
     list-style-type: none; 
 
     padding: 0; 
 
     width: 50em; 
 
    } 
 
    .posts li { 
 
     position: relative; 
 
     left: 0; 
 
     background-color: #EEE; 
 
     margin: .5em; 
 
     padding: .3em 0; 
 
     height: 20em; 
 
     border-radius: 4px; 
 
    } 
 
    .posts .text { 
 
     position: relative; 
 
     top: -3px; 
 
    }
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> 
 
</script> 
 
<div ng-app="myApp" ng-controller="postsCtrl"> 
 
    <h1>GWAT Websites and Designs</h1> 
 

 
    <ul class="posts"> 
 
     <li *ng-repeat="post in names.retRows"> 
 
      {{post.title}}<br> 
 
      {{post.pBody}}<br> 
 
      {{post.category}}<br> 
 
      <iframe ng-src="{{myUrl}}"></iframe><br><br> 
 
     </li> 
 
     </ul> 
 
</div>

+0

这个修复该问题与我居然也得到了错误,但它已不再通过NG-重复循环有任何明显的原因在HTML我不认为这可能是Node.js的文件我是运行,因为这没有改变,但我可以添加,如果有必要 –

+0

张贴json数组 –

+0

nvm由于某种原因,我必须改变一些东西,停止需要我使用names.retRows,而不是只需要名称现在 –