【发布时间】:2014-06-09 15:01:45
【问题描述】:
我的控制器中定义了一个作用域函数,它调用 API 从数据库中获取数据。我在 ng-repeat 中使用了这个作用域函数。但是当我运行应用程序时,它被挂起,我对脏检查知之甚少,但我不知道如何处理这种情况。
在我的控制器中:
$scope.GetTranslatedText = function (categoryID, categoryDetailID, languageID) {
$http.get('api/datacategorydetailtranslations' + '/' + categoryID + '/' + categoryDetailID + '/' + languageID).
success(function (data) {
return data.datacategorydetailtranslations;
});
};
Index.jade 内部
li(ng-repeat="property in properties track by property.PropertyID | orderBy : 'Region'" ng-init="abc=compute()" menuhover itemscope itemtype="http://schema.org/Hotel")
a(ng-href='{{property.UrlName}}')
img.hotelImage(ng-src='http://cdn.objects.florahospitality.com/media/property/thumbnail/{{property.PropertyThumbnail}}' alt="{{property.PropertyName}}" style="height:36px;width:40px;")
div.column2
p.hotelName(itemprop="name") {{property.PropertyName}}
div.thumbsUpNav(florapopover template="thumbsUpNav")
span.sprite_image.white_thumbs_up_icon
p.starRating
span(class="{{property.StarRating}}")
span(ng-show="property.Visible", style="width:310px;") {{property.StarRating}}
p.hotelAddress
span(itemprop="location") {{GetTranslatedText(2, property.StreetAddress, 1)}}
span.viewMap(data-item="4" itemprop="geo" itemscope="" itemtype="http://schema.org/GeoCoordinates") (Show Map)
meta(itemprop="latitude" content="25.2530800688814")
meta(itemprop="latitude" content="55.3282535076141")
【问题讨论】:
-
你需要在哪里调用你的api? PS:如果您正在寻找翻译功能,角度有一个库。 Thay 可能会让您的生活更轻松。