我要求在textarea元素中包含可点击链接。我使用Angular的ng-model设置textarea的值。请告诉我如何实现这一目标。
游戏演示低于
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.url = "http://stackoverflow.com/"
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!DOCTYPE html>
<html ng-app="myApp" >
<head>
<script src="https://code.angularjs.org/1.4.9/angular.js"></script>
</head>
<body>
<div ng-controller="myCtrl">
<textarea ng-model = "url"></textarea>
</div>
</body>
</html>
答案 0 :(得分:0)
你可以试试这个,可能对你有所帮助
HTML
<div ng-controller="myCtrl">
<textarea class="textAreaLink" ng-model = "url" ng-click="callFunction()"></textarea>
</div>
CSS
.textAreaLink{color: blue;cursor: pointer}
.textAreaLink:hover{color: blue;text-decoration: underline;}
JS
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $location) {
$scope.url = "http://stackoverflow.com/";
$scope.callFunction = function(){
$location.path($scope.url);
}
});