私のannounce.objにリンクがあります。しかし、クリックすると、ブラウザに間違ったURL(http://www./)が表示されます。
html
<p>
<a ng-href="{{data.links}}" target="_blank">{{data.links}}</a>
</p>
data.links値
www.google.com
リンクをデータベースなどに保存するときにhttpsを追加する必要がありますか?
次のように試してください$scope.myVar = 'https://www.w3schools.com';
:
var app = angular.module('myAngularApp', []);
var myController = app.controller('myController', MyController);
myController.$inject = ['$scope'];
function MyController($scope){
$scope.myVar = 'https://www.w3schools.com';
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html>
<body ng-app="myAngularApp">
<div ng-controller = "myController">
<h1>Tutorials</h1>
<p>Go to <a ng-href="{{myVar}}">{{myVar}}</a> to learn!</p>
</div>
<p>This example could use the original href attribute, but in AngularJS, the ng-href attribute is safer.</p>
</body>
</html>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加