HTML没有显示Angularjs的变量值

时间:2015-06-05 21:08:47

标签: javascript html angularjs umbraco

我尝试使用以下代码在HTML中显示Angularjs的变量值:

angular.module("umbraco").controller("MyTextbox", function ($scope,$routeParams) {

$scope.nodeID1 = "Hello World";

这是我的angularjs控制器的代码:

<style name="LightSearchView" parent="@android:style/Theme.NoTitleBar.Fullscreen">
 <!-- SearchView attributes -->
    <item name="android:searchDropdownBackground">@android:drawable/search_dropdown_light</item>
    <item name="android:searchViewTextField">@drawable/textfield_searchview_holo_light</item>
    <item name="android:searchViewTextFieldRight">@drawable/textfield_searchview_right_holo_light</item>
    <item name="android:searchViewCloseIcon">@android:drawable/ic_clear_holo_light</item>
    <item name="android:searchViewSearchIcon">@android:drawable/ic_search_api_holo_light</item>
    <item name="android:searchViewGoIcon">@android:drawable/ic_go_search_api_holo_light</item>
    <item name="android:searchViewVoiceIcon">@android:drawable/ic_voice_search_api_holo_light</item>
    <item name="android:searchViewEditQuery">@android:drawable/ic_commit_search_api_holo_light</item>
</style>

});

但没有任何东西以这种方式显示。 有什么帮助吗?

2 个答案:

答案 0 :(得分:1)

您需要在ng-app="umbraco"指令之前编写ng-controller,或者将其写在body / html标记上更好。

<强>标记

<div ng-app="umbraco" ng-controller="MyTextbox">

    <p>Fecha de ultima actualizacion: {{nodeID1}} </p>

</div>

,你的应用应该是

angular.module("umbraco",[]).controller("MyTextbox", function ($scope,$routeParams) {

     $scope.nodeID1 = "Hello World";
});

注意

  

如果$routeParams未添加错误,那么您的应用就是   angular.module("umbraco",['ngRoute'])然后您需要另外添加angular-route.js

答案 1 :(得分:0)

尝试:

var _ = require('lodash');
var a = ['a', 'b', 'c', 'd'];
var b = _.cloneDeep(a);