Lautaro Lautaro - 1 year ago 99
TypeScript Question

Setting the title with Angular

I'm trying to work with an Angular app I don't know so much about. It uses TypeScript Angular 1.5. I need to be able to change the page's title. This is what I have to work with. I'm not sure how it works without ng-app specified, but it works.

Is there a way to set the title in the head dynamically? Or would I need to change the ng-controller attr to the html element? If so how could it affect the system?

<!DOCTYPE html>

<html lang="sv">

<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/styles.css" rel="stylesheet">

<body ng-controller="AppController as vm" ng-class="{ 'v-dolj-overflow': vm.togglaScroll }">


<div class="v--header-offset" ui-view></div>

<script src="js/app.js"></script>
<script src="js/angular-locale_sv.js"></script>



Answer Source

You should be able to accomplish this with document.title regardless of where the controller lives

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download