目标实现:通过点击<li>标签的点击事件改变<p>标签的内容
<div ng-app="MyApp" ng-controller="MyCtrl">
<p ng-model ="myText" ng-init = "myText = '大连'">{{myText}}</p>
<ul>
<li ng-repeat = "x in citys">
<a href="#" ng-click="myClick(x)">{{x}}</a>
</li>
</ul>
</div>
<script>
var myApp = angular.module("MyApp", []);
myApp.controller("MyCtrl", function ($scope){
$scope.citys = ["大连", "北京", "上海"];
$scope.myClick = function (x){
$scope.myText = x;
};
});
</script>
网友评论