0
入力をフォーカスして入力をぼかすと、別のテキストを表示する必要があります。`displayText`を変更し、入力をフォーカスするときに` displayText`を表示する方法は?
私がinput
にマウスを下ろして、displayText
を変更してdisplayText
と表示したい場合は、「networkText」と表示されます。
これは、以下の私のコードです:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.centerBigView {
margin: auto;
width: 900px;
height: 1000px;
background-color: rebeccapurple;
}
.topSearchView {
margin: 20px auto;
width: 300px;
height: 40px;
background-color: yellow;
}
.topSearchView input {
display: block;
margin: auto;
}
.resultView {
margin: auto;
width: 600px;
background-color: darkgrey;
}
li {
color: white;
}
</style>
</head>
<script src="angular.js"></script>
<body ng-app="searchAPP" ng-controller="controller11">
<div class="centerBigView">
<div class="topSearchView">
<input type="text"
blurred-focused='databaseForm.connectionName' displayText="" name="connectionName">
</div>
<div class="resultView">
<ul>
<li>
<span>{{displayText}}</span>
</li>
</ul>
</div>
</div>
<script>
var app = angular.module("searchAPP", []);
app.controller('controller11', ['$scope', function ($scope) {
$scope.displayText = "nature animal plant";;
}]);
app.directive("blurredFocused", [function() {
return {
restrict: "A",
priority: -1,
scope: {
blurredFocused: "="
},
link: function (scope, ele, attrs) {
ele.on("blur", function() {
scope.$apply(function() {
});
});
ele.on("focus", function() {
scope.$apply(
attrs.displayText = "networkText";
);
})
}
}
}]);
</script>
</body>
</html>
- ここで ' {{displayText}}'は 'resultView'にありますか? –
resultViewに{{displayText}}を表示します。 – jiexishede
[my answer](http://stackoverflow.com/a/39928897/2545680)を参照してください。 –