Angular JS大写不起作用

时间:2017-04-30 07:01:35

标签: javascript angularjs

此代码无效。直接打印{{name |大写}} ..

你能帮助我吗?

  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <body ng-app="myApp">
    <p>Name:<input type="text" ng-model="name">
    </p>
    <h3>{{ name | uppercase }}</h3>

1 个答案:

答案 0 :(得分:0)

您的 ng-controller 缺失

试试这个:

<div ng-app="myApp" ng-controller="caseCtrl">
<input type="text" ng-model="txt" />
<h3>{{txt | uppercase}}</h3>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('caseCtrl', function($scope) {
    $scope.txt = "Hello World!";
});
</script>