<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script src="angular.min.js"></script> <script> var m1 = angular.module(‘myApp‘,[]); m1.controller(‘may‘,[‘$scope‘,‘$interpolate‘,function ($scope,$interpolate){ $scope.$watch(‘key‘,function(newVal){ if(newVal){ var temp = $interpolate(newVal); $scope.showtime = temp({name:$scope.name}) } }); $scope.$watch(‘name‘,function(newVal){ if(newVal){ var temp = $interpolate(newVal); $scope.showtime = temp({name:$scope.name}) } }) }]) </script> </head> <body ng-controller=‘may‘> <input type="text" ng-model=‘name‘> <textarea ng-model=‘key‘></textarea> <p>{{showtime}}</p> </body> </html>
时间: 2024-10-22 02:08:43