我一直在搜索周围下午试图弄清楚如何使用Typescript来改变我的面包屑路径中的span元素的html,或者得到一个角度语句来评估/编译在jQuery选择器中。我发现的最接近的是使用$ compile,但我不确定这是否可以工作,因为直到我的解决方案完成之后才有数据?如果会的话,我需要了解将$ compile注入应用程序的位置。Typescript - 更改DOM元素内部HTML?
index.module.ts
angular.module('pccrm', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource',
'ui.router', 'ui.bootstrap', 'feature-flags', 'trNgGrid', 'pascalprecht.translate', 'toastr', 'cgBusy',
'fixtable', 'angularUtils.directives.uiBreadcrumbs', 'LocalStorageModule'])
...
index.route.ts
...
.state(Constants.SEARCH_CONTACTS_CONTACTPROFILE, {
url: '/orgs/:externalOrgId/contacts/:profileId',
data: {
displayName: 'Contact Profile'
},
views: {
'': {
templateUrl: 'app/contacts/contact-profile.tmpl.html',
controller: 'ContactsProfileController',
controllerAs: 'cpc',
resolve: {
contactProfile: function (contactProfileService: IContactProfileService, $stateParams: any) {
return contactProfileService.getContactProfile(<string>$stateParams.externalOrgId, <string>$stateParams.profileId)
.then(function (contactModel: IContact) {
return contactModel;
});
}
}
}
}
})
...
接触profile.tmpl.html
...
<div class="info-group">
<div class="profileImage default">
</div>
<h4 class="contact-name">{{ cpc.contactProfile.fullName() }}</h4>
{{ cpc.contactProfile.title }}<br/>
<a ui-sref="search.organizations.orgProfile({externalOrgId: cpc.contactProfile.externalOrganizationId })" ng-if="cpc.contactProfile.externalOrganizationId">
{{ cpc.contactProfile.externalOrganizationName }}
</a>
</div>
...
是类似的...
<script type="text/javascript">
$('.breadcrumb li.active span').html(
$compile("{{ cpc.contactProfile.fullName() }}")(scope));
</script>
在模板的末尾html最好的方法来做到这一点?或者我的个人资料服务可以在检索联系信息后以某种方式编辑DOM?
注意我们使用angular-util-sui-breadcrumbs来生成BCT ......它目前不支持用我们嵌套的命名视图插入到BCT的解决方案。这就是为什么我需要能够在事后修改BCT dom的原因。
我还有一个问题angularjs。你愿意对此发表评论吗?发布答案的用户在没有详细说明的情况下起飞。这里是链接:http://stackoverflow.com/questions/35588344/how-do-i-connect-this-interval-service-to-a-view – CodeMed
你可能误解了我的问题。你可以在我的联系人档案html中看到我已经在我的html中获得了值。我遇到的问题是获取角度值到jquery选择器中。否则,请修改打字稿控制器或服务内的dom。 – NikZ
@NikZ请参阅更新。我不认为我误解了你的问题。 – basarat