This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(linky): mention sanitization, improve formatting
- Loading branch information
Showing
1 changed file
with
19 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,13 @@ | |
* @kind function | ||
* | ||
* @description | ||
* Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and | ||
* Finds links in text input and turns them into html links. Supports `http/https/ftp/mailto` and | ||
* plain email address links. | ||
* | ||
* Requires the {@link ngSanitize `ngSanitize`} module to be installed. | ||
* | ||
* @param {string} text Input text. | ||
* @param {string} target Window (_blank|_self|_parent|_top) or named frame to open links in. | ||
* @param {string} target Window (`_blank|_self|_parent|_top`) or named frame to open links in. | ||
* @param {object|function(url)} [attributes] Add custom attributes to the link element. | ||
* | ||
* Can be one of: | ||
|
@@ -25,33 +25,22 @@ | |
* If the map of attributes contains a value for `target`, it overrides the value of | ||
* the target parameter. | ||
* | ||
* @returns {string} Html-linkified text. | ||
* | ||
* @returns {string} Html-linkified and {@link $sanitize sanitized} text. | ||
* | ||
* @usage | ||
<span ng-bind-html="linky_expression | linky"></span> | ||
* | ||
* @example | ||
<example module="linkyExample" deps="angular-sanitize.js"> | ||
<file name="index.html"> | ||
<script> | ||
angular.module('linkyExample', ['ngSanitize']) | ||
.controller('ExampleController', ['$scope', function($scope) { | ||
$scope.snippet = | ||
'Pretty text with some links:\n'+ | ||
'http://angularjs.org/,\n'+ | ||
'mailto:[email protected],\n'+ | ||
'[email protected],\n'+ | ||
'and one more: ftp://127.0.0.1/.'; | ||
$scope.snippetWithSingleURL = 'http://angularjs.org/'; | ||
}]); | ||
</script> | ||
<div ng-controller="ExampleController"> | ||
Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea> | ||
<table> | ||
<tr> | ||
<td>Filter</td> | ||
<td>Source</td> | ||
<td>Rendered</td> | ||
<th>Filter</th> | ||
<th>Source</th> | ||
<th>Rendered</th> | ||
</tr> | ||
<tr id="linky-filter"> | ||
<td>linky filter</td> | ||
|
@@ -87,6 +76,18 @@ | |
</tr> | ||
</table> | ||
</file> | ||
<file name="script.js"> | ||
angular.module('linkyExample', ['ngSanitize']) | ||
.controller('ExampleController', ['$scope', function($scope) { | ||
$scope.snippet = | ||
'Pretty text with some links:\n'+ | ||
'http://angularjs.org/,\n'+ | ||
'mailto:[email protected],\n'+ | ||
'[email protected],\n'+ | ||
'and one more: ftp://127.0.0.1/.'; | ||
$scope.snippetWithSingleURL = 'http://angularjs.org/'; | ||
}]); | ||
</file> | ||
<file name="protractor.js" type="protractor"> | ||
it('should linkify the snippet with urls', function() { | ||
expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()). | ||
|