How-to: આ જ પેજ પર બહુવિધ કોણીય શેરપોઈન્ટ વેબ પાર્ટ્સ સક્રિય

This blog posts describes how you can have multiple Angular.js based SharePoint web parts (referenced via a content editor web part) on the same page. I’m calling a content editor web part (CEWP) that references JavaScript built using the Angular.js framework an “Angular Web Part.”

Angular’s bootstrap process is super easy and just about every example you find on the internets goes something like this:

<html ng-app=’myApp’>

<blah/><blah/><blah/>

</HTML>

This breaks down, તેમ છતાં, if you want to enable multiple CEWP’s representing multiple angular web parts on the same page. Angular will only automatically bootstrap against the first ng-app directive it finds – at least as of angular version 1.3.6. The solution is pretty simple – manually bootstrap your code instead. The above now changes to something like this:

<સંસ્થા>
<ડી
iv id=”bootstrapHere” ng-controller=”myController as theController”>
<blah/><blah/><blah/>
</div>
</સંસ્થા>

<script src=”//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js”></લિપિ>

<લિપિ>
angular.bootstrap(angular.element(document.getElementById(“bootstrapHere”)),[‘myApp’]);
</લિપિ>

મૂળભૂત રીતે, instead of using ng-app on the element to do your bootstrapping, you slap an ID onto that element. તે પછી, use the bootstrap() method on angular itself to control the bootstrapping process at run-time. I’ve tested this with three different Angular web parts on the same page and it works a charm.

</અંત>

undefinedમારા બ્લોગ પર સબ્સ્ક્રાઇબ કરો.

Twitter પર મને ખાતે અનુસરો http://www.twitter.com/pagalvin

5 પર "વિચારોHow-to: આ જ પેજ પર બહુવિધ કોણીય શેરપોઈન્ટ વેબ પાર્ટ્સ સક્રિય

    1. પીડી Galvin પોસ્ટ લેખક

      Great question. આ કિસ્સામાં, I did it using SharePoint online (O365).

      I *believe* that my colleagie also did this in SP 2013 on-prem.

      I posted a question to reddit.com/r/angularjs, asking whether this should sort of be standard. The limited feedbcak I got was that yes, manual bootstrapping is the way to go. Just some opinions.

  1. Pingback: Manual or automatic bootstrapping Angular on a page – it seems like manual bootstrapping is safest? - Reader

  2. Pingback: SharePoint 2013: Recopilatorio de enlaces interesantes (LXI)! | Pasión por la tecnología...

  3. Pingback: SharePoint 2013: Recopilatorio de enlaces interesantes (LXI)! - Blog de Juan Carlos González en Geeks.MS

જવાબ છોડો

તમારું ઇમેઇલ સરનામું પ્રકાશિત કરવામાં આવશે નહીં. જરૂરી ક્ષેત્રો ચિહ્નિત થયેલ છે *