angular.js - Display problem with angularJS ng-show
世界只因有你
世界只因有你 2017-05-15 17:04:08
0
4
574

angularJS has been introduced, but it has no effect. Please God, take a look! !

世界只因有你
世界只因有你

reply all(4)
PHPzhong

ng-show doesn’t seem to be used in this way, right? It seems that a bool type value is passed to ng-show. True means display and false means hiding. The function you write should return a default value. You put the return true inside the if condition, and there is another one outside. Default return value

習慣沉默

Whether this code will be executed or not is a question. It is recommended to take a look at angular’s ​​official demo

Ty80

angular已经引入了,那么你的ng-app声明了没有,ng-controller声明了没有,如果都有的话,你的rec函数应该是定义在$scope中或者controller中暴露出来,而不是直接写成一个函数,这样angular can find this function

漂亮男人
var test = angular.module('test', []);//申明应用

test.controller("testCon",function($scope){//申明控制器
    $scope.rec = function(){
        //your code
    }
})

Finally, add ng-controller to the ancestor p other than the p you need to control
For example: <p ng-controller="testCon"><p ng-controller="testCon">
再在你controller的祖辈p或者body中添加ng-app
如:<body ng-app="test">
然后在你需要ng-show的地方后面只需要函数名
如:ng-show=“rec” Then add ng-controller to the ancestor p or body of your controller Add ng-app

for example: <body ng-app="test">🎜Then just the function name after the place where you need ng-show🎜for example: ng- show="rec"🎜
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template