2016-06-20 3 views
1

나는 오차드로 웹 사이트를 만들고 있습니다. AngularJS를 사용하면 ASP.NET 웹 API 프로젝트에서 데이터를 읽고 웹 사이트에 데이터를 표시하고 있습니다. 내가하고 싶은 것은 페이지의 제목과 메타 데이터를 표시하는 것입니다.과수원 CMS에 동적으로 제목을 추가하십시오.

나는 제목이 시도했다, 그러나 나는 다음과 같은 오류가 발생합니다 :

<div ng-controller="bookDetailController" data-ng-init="AddReaded()" ng-cloak> 
@{ 
    Layout.Title = {{book.Title}}; 
    } 

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0820: Cannot initialize an implicitly-typed local variable with an array initializer

이제까지 프론트 엔드의 변화를 알 수 없습니다, 그래서 면도기는, 서버 측에서 컴파일
+0

면도기는 서버 측에서 컴파일, 그래서 이제까지 변경 알 수 없습니다 프론트 엔드에. – devqon

답변

4

. 여러분과 함께 제목을 추가 할

angular.module("myApp", []) 
    .directive("pageTitle", function($document) { 
     return { 
      restrict: "A", 
      scope: { 
       pageTitle: "=", 
      }, 
      link: function(scope, elem) { 
       scope.$watch("pageTitle", function(newval) { 
        $document.title = newval; 
       }); 
      } 
     } 
    }); 

: 당신이 대신 할 수있는 것은이 같은 몇 가지 지침을 만드는 것입니다

<div 
    ng-controller="bookDetailController" 
    data-ng-init="AddReaded()" 
    ng-cloak 
    page-title="book.Title"> 
+1

'$ document.title = newval '로'angular.element ("title"). text (newval);을 대체하고'$ document'도 삽입 할 수 있습니다. – Martin

관련 문제