我如何 select 包含特定文本值的跨度
How do I select a span containing a specific text value
我想查找并替换 span 元素的样式。
我知道 JQuery
是怎么做的
$("span:contains('OVERVIEW')").text("OVERVIEW "+ localStorage.getItem("shape"));
上面的 angular 等价物是什么?
我们可以用ng-bind来实现。以下示例代码供您参考。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
<script src="//code.angularjs.org/snapshot/angular.min.js"></script>
<script>
angular.module('bindExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.name = 'OVERVIEW'+localStorage.getItem("shape");
}]);
</script>
</head>
<body ng-app="bindExample">
<div ng-controller="ExampleController">
<span ng-bind="name">OVERVIEW</span>
</div>
</body>
</html>
我想查找并替换 span 元素的样式。
我知道 JQuery
是怎么做的$("span:contains('OVERVIEW')").text("OVERVIEW "+ localStorage.getItem("shape"));
上面的 angular 等价物是什么?
我们可以用ng-bind来实现。以下示例代码供您参考。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
<script src="//code.angularjs.org/snapshot/angular.min.js"></script>
<script>
angular.module('bindExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.name = 'OVERVIEW'+localStorage.getItem("shape");
}]);
</script>
</head>
<body ng-app="bindExample">
<div ng-controller="ExampleController">
<span ng-bind="name">OVERVIEW</span>
</div>
</body>
</html>