Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJs:ng在变量中使用函数并返回一些文本时绑定不起作用_Angularjs - Fatal编程技术网

AngularJs:ng在变量中使用函数并返回一些文本时绑定不起作用

AngularJs:ng在变量中使用函数并返回一些文本时绑定不起作用,angularjs,Angularjs,有角度的,它是在返回一些扭曲的东西 我有一个控制器: app.controller('indexViewController', ['LocalizationHandler', function (LocalizationHandler) { var self = this; self.Nombre = function () { return "asdfasdf"; }; }]); 在html中,我有: <body

有角度的,它是在返回一些扭曲的东西

我有一个控制器:

app.controller('indexViewController', ['LocalizationHandler', function (LocalizationHandler) {
    var self = this;        

    self.Nombre = function ()    {
        return "asdfasdf";
    };    
}]);
在html中,我有:

<body ng-controller="indexViewController as IndexVM">
...
<span ng-bind="IndexVM.Nombre"></span>
...
</body>

要查看Nombre的文本,我必须做些什么?

您必须执行该函数!(通过
()
调用它)


Nombre是一个函数,当放入ng绑定时,它将显示为一个字符串,其中包含代码

现在,IndexVM.Nombre()是函数的结果。这会给你你所期望的

<span ng-bind="IndexVM.Nombre()"></span>

我在屏幕上看到的是一行功能,而不是您建议的三行功能。请不要再抱怨了,因为你的改变不会是真的
ng-bind="IndexVM.Nombre()"
<span ng-bind="IndexVM.Nombre()"></span>