2017-04-21 125 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,而不是隻需要名稱現在 –